Superclass intended for user-visible errors Instead of stacktraces, these will be prettyprinted. The suggested error message guidelines are the same as for the PostgreSQL project: http://developer.postgresql.org/pgdocs/postgres/error-style-guide.html If it is necessary t
| 4 | |
| 5 | |
| 6 | class UserException(Exception): |
| 7 | """ |
| 8 | Superclass intended for user-visible errors |
| 9 | |
| 10 | Instead of stacktraces, these will be prettyprinted. The |
| 11 | suggested error message guidelines are the same as for the |
| 12 | PostgreSQL project: |
| 13 | |
| 14 | http://developer.postgresql.org/pgdocs/postgres/error-style-guide.html |
| 15 | |
| 16 | If it is necessary to trap these exceptions, use a subclass. |
| 17 | |
| 18 | >>> raise UserException(msg='foo', detail='bar') |
| 19 | Traceback (most recent call last): |
| 20 | ... |
| 21 | UserException: ERROR: MSG: foo |
| 22 | DETAIL: bar |
| 23 | STRUCTURED: time=... pid=... |
| 24 | >>> raise UserException(msg='foo', detail='bar', hint='hello') |
| 25 | Traceback (most recent call last): |
| 26 | ... |
| 27 | UserException: ERROR: MSG: foo |
| 28 | DETAIL: bar |
| 29 | HINT: hello |
| 30 | STRUCTURED: time=... pid=... |
| 31 | """ |
| 32 | |
| 33 | def __init__(self, msg=None, detail=None, hint=None): |
| 34 | # msg uses a keyword argument with a default to make the |
| 35 | # multiprocessing module happy, as it seems to set them after |
| 36 | # the fact. Realistically, one should *always* be setting msg |
| 37 | # when used in normal code though. |
| 38 | self.msg = msg |
| 39 | self.detail = detail |
| 40 | self.hint = hint |
| 41 | self.severity = ERROR |
| 42 | |
| 43 | def __str__(self): |
| 44 | return "{0}: {1}".format(getLevelName(self.severity), |
| 45 | WalELogger.fmt_logline(self.msg, self.detail, self.hint)) |
| 46 | |
| 47 | |
| 48 | class UserCritical(UserException): |
no outgoing calls
no test coverage detected