Better exception handling

This commit is contained in:
slush 2013-01-05 14:42:09 +00:00
parent 68d46cb2f9
commit 842720052a
2 changed files with 10 additions and 7 deletions

View File

@ -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()

View File

@ -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")