Fix the ClientSideError constructor so that it is propertly displayed in the backtrace
This commit is contained in:
parent
a8d0e8e79e
commit
0f0d9e901d
15
wsme/exc.py
15
wsme/exc.py
@ -1,11 +1,12 @@
|
||||
import six
|
||||
from six.moves import builtins
|
||||
|
||||
if '_' not in builtins.__dict__:
|
||||
builtins._ = lambda s: s
|
||||
from wsme.utils import _
|
||||
|
||||
|
||||
class ClientSideError(RuntimeError):
|
||||
def __init__(self):
|
||||
super(ClientSideError, self).__init__(self.faultstring)
|
||||
|
||||
@property
|
||||
def faultstring(self):
|
||||
return str(self)
|
||||
@ -16,18 +17,20 @@ class InvalidInput(ClientSideError):
|
||||
self.fieldname = fieldname
|
||||
self.value = value
|
||||
self.msg = msg
|
||||
super(InvalidInput, self).__init__()
|
||||
|
||||
@property
|
||||
def faultstring(self):
|
||||
return _(six.u(
|
||||
"Invalid input for field/attribute %s. Value: '%s'. %s")) % (
|
||||
self.fieldname, self.value, self.msg)
|
||||
"Invalid input for field/attribute %s. Value: '%s'. %s")
|
||||
) % (self.fieldname, self.value, self.msg)
|
||||
|
||||
|
||||
class MissingArgument(ClientSideError):
|
||||
def __init__(self, argname, msg=''):
|
||||
self.argname = argname
|
||||
self.msg = msg
|
||||
super(MissingArgument, self).__init__()
|
||||
|
||||
@property
|
||||
def faultstring(self):
|
||||
@ -39,6 +42,7 @@ class UnknownArgument(ClientSideError):
|
||||
def __init__(self, argname, msg=''):
|
||||
self.argname = argname
|
||||
self.msg = msg
|
||||
super(UnknownArgument, self).__init__()
|
||||
|
||||
@property
|
||||
def faultstring(self):
|
||||
@ -49,6 +53,7 @@ class UnknownArgument(ClientSideError):
|
||||
class UnknownFunction(ClientSideError):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
super(UnknownFunction, self).__init__()
|
||||
|
||||
@property
|
||||
def faultstring(self):
|
||||
|
@ -1,6 +1,7 @@
|
||||
import decimal
|
||||
import datetime
|
||||
import re
|
||||
from six.moves import builtins
|
||||
|
||||
date_re = r'(?P<year>-?\d{4,})-(?P<month>\d{2})-(?P<day>\d{2})'
|
||||
time_re = r'(?P<hour>\d{2}):(?P<min>\d{2}):(?P<sec>\d{2})' + \
|
||||
@ -14,6 +15,13 @@ date_re = re.compile(date_re)
|
||||
time_re = re.compile(time_re)
|
||||
|
||||
|
||||
if hasattr(builtins, '_'):
|
||||
_ = builtins._
|
||||
else:
|
||||
def _(s):
|
||||
return s
|
||||
|
||||
|
||||
def parse_isodate(value):
|
||||
m = date_re.match(value)
|
||||
if m is None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user