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