Revision 3109
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
38 | 38 |
DbException.__init__(self, 'for name: '+strings.as_tt(str(name)), cause) |
39 | 39 |
self.name = name |
40 | 40 |
|
41 |
class ExceptionWithNameValue(DbException): |
|
42 |
def __init__(self, name, value, cause=None): |
|
43 |
DbException.__init__(self, 'for name: '+strings.as_tt(str(name)) |
|
44 |
+'; value: '+strings.as_tt(repr(value)), cause) |
|
45 |
self.name = name |
|
41 |
class ExceptionWithValue(DbException): |
|
42 |
def __init__(self, value, cause=None): |
|
43 |
DbException.__init__(self, 'for value: '+strings.as_tt(repr(value)), |
|
44 |
cause) |
|
46 | 45 |
self.value = value |
47 | 46 |
|
48 | 47 |
class ExceptionWithNameType(DbException): |
... | ... | |
72 | 71 |
|
73 | 72 |
class NullValueException(ConstraintException): pass |
74 | 73 |
|
75 |
class FunctionValueException(ExceptionWithNameValue): pass
|
|
74 |
class InvalidValueException(ExceptionWithValue): pass
|
|
76 | 75 |
|
77 | 76 |
class DuplicateException(ExceptionWithNameType): pass |
78 | 77 |
|
... | ... | |
457 | 456 |
if match: raise NullValueException('NOT NULL', [match.group(1)], e) |
458 | 457 |
|
459 | 458 |
match = re.match(r'^(?:invalid input (?:syntax|value)\b.*?' |
460 |
r'|date/time field value out of range): "(.+?)"\n' |
|
461 |
r'(?:(?s).*?)\bfunction "(.+?)"', msg) |
|
459 |
r'|.+? field value out of range): "(.+?)"', msg) |
|
462 | 460 |
if match: |
463 |
value, name = match.groups()
|
|
464 |
raise FunctionValueException(name, strings.to_unicode(value), e)
|
|
461 |
value, = match.groups() |
|
462 |
raise InvalidValueException(strings.to_unicode(value), e)
|
|
465 | 463 |
|
466 | 464 |
match = re.match(r'^column "(.+?)" is of type (.+?) but expression ' |
467 | 465 |
r'is of type', msg) |
Also available in: Unified diff
sql.py: Generalized FunctionValueException to InvalidValueException so that it will match all invalid-value errors, not just those occurring in user-defined functions