simplyfy some error messages
This commit is contained in:
@ -138,6 +138,12 @@ def secop_error(exception):
|
|||||||
return InternalError(repr(exception))
|
return InternalError(repr(exception))
|
||||||
|
|
||||||
|
|
||||||
|
def fmt_error(exception):
|
||||||
|
if isinstance(exception, SECoPError):
|
||||||
|
return str(exception)
|
||||||
|
return repr(exception)
|
||||||
|
|
||||||
|
|
||||||
EXCEPTIONS = dict(
|
EXCEPTIONS = dict(
|
||||||
NoSuchModule=NoSuchModuleError,
|
NoSuchModule=NoSuchModuleError,
|
||||||
NoSuchParameter=NoSuchParameterError,
|
NoSuchParameter=NoSuchParameterError,
|
||||||
|
@ -43,7 +43,7 @@ from collections import OrderedDict
|
|||||||
from time import time as currenttime
|
from time import time as currenttime
|
||||||
|
|
||||||
from secop.errors import BadValueError, NoSuchCommandError, NoSuchModuleError, \
|
from secop.errors import BadValueError, NoSuchCommandError, NoSuchModuleError, \
|
||||||
NoSuchParameterError, ProtocolError, ReadOnlyError, SECoPServerError
|
NoSuchParameterError, ProtocolError, ReadOnlyError, SECoPServerError, fmt_error
|
||||||
from secop.params import Parameter
|
from secop.params import Parameter
|
||||||
from secop.protocol.messages import COMMANDREPLY, DESCRIPTIONREPLY, \
|
from secop.protocol.messages import COMMANDREPLY, DESCRIPTIONREPLY, \
|
||||||
DISABLEEVENTSREPLY, ENABLEEVENTSREPLY, ERRORPREFIX, EVENTREPLY, \
|
DISABLEEVENTSREPLY, ENABLEEVENTSREPLY, ERRORPREFIX, EVENTREPLY, \
|
||||||
@ -53,8 +53,8 @@ from secop.protocol.messages import COMMANDREPLY, DESCRIPTIONREPLY, \
|
|||||||
def make_update(modulename, pobj):
|
def make_update(modulename, pobj):
|
||||||
if pobj.readerror:
|
if pobj.readerror:
|
||||||
return (ERRORPREFIX + EVENTREPLY, '%s:%s' % (modulename, pobj.export),
|
return (ERRORPREFIX + EVENTREPLY, '%s:%s' % (modulename, pobj.export),
|
||||||
# error-report !
|
# error-report !
|
||||||
[pobj.readerror.name, repr(pobj.readerror), dict(t=pobj.timestamp)])
|
[pobj.readerror.name, fmt_error(pobj.readerror), dict(t=pobj.timestamp)])
|
||||||
return (EVENTREPLY, '%s:%s' % (modulename, pobj.export),
|
return (EVENTREPLY, '%s:%s' % (modulename, pobj.export),
|
||||||
[pobj.export_value(), dict(t=pobj.timestamp)])
|
[pobj.export_value(), dict(t=pobj.timestamp)])
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user