Better exception handling

pull/1/head
slush 12 years ago
parent 68d46cb2f9
commit 842720052a

@ -1,25 +1,28 @@
import struct
import mapping
class NotImplementedException(Exception):
pass
class Transport(object):
def __init__(self, device, *args, **kwargs):
self.device = device
self._open()
def _open(self):
raise NotImplemented
raise NotImplementedException("Not implemented")
def _close(self):
raise NotImplemented
raise NotImplementedException("Not implemented")
def _write(self, msg):
raise NotImplemented
raise NotImplementedException("Not implemented")
def _read(self):
raise NotImplemented
raise NotImplementedException("Not implemented")
def ready_to_read(self):
raise NotImplemented
raise NotImplementedException("Not implemented")
def close(self):
self._close()

@ -2,7 +2,7 @@
# Local serial port loopback: socat PTY,link=COM8 PTY,link=COM9
from transport import Transport
from transport import Transport, NotImplementedException
class FakeTransport(Transport):
def __init__(self, device, *args, **kwargs):
@ -21,4 +21,4 @@ class FakeTransport(Transport):
pass
def _read(self):
raise NotImplemented
raise NotImplementedException("Not implemented")
Loading…
Cancel
Save