simplyfy some error messages

This commit is contained in:
l_samenv 2020-09-08 13:31:38 +02:00
parent c1ffc160a2
commit 99e32065b1
2 changed files with 9 additions and 3 deletions

View File

@ -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,

View File

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