Exception thrown by :func:`pwnlib.log.error`. Pwnlib functions that encounters unrecoverable errors should call the :func:`pwnlib.log.error` function instead of throwing this exception directly.
| 4 | |
| 5 | |
| 6 | class PwnlibException(Exception): |
| 7 | '''Exception thrown by :func:`pwnlib.log.error`. |
| 8 | |
| 9 | Pwnlib functions that encounters unrecoverable errors should call the |
| 10 | :func:`pwnlib.log.error` function instead of throwing this exception directly.''' |
| 11 | def __init__(self, msg, reason = None, exit_code = None): |
| 12 | '''bar''' |
| 13 | Exception.__init__(self, msg) |
| 14 | self.reason = reason |
| 15 | self.exit_code = exit_code |
| 16 | self.message = msg |
| 17 | |
| 18 | def __repr__(self): |
| 19 | s = 'PwnlibException: %s' % self.message |
| 20 | if self.reason: |
| 21 | s += '\nReason:\n' |
| 22 | s += ''.join(traceback.format_exception(*self.reason)) |
| 23 | elif sys.exc_info()[0] not in [None, KeyboardInterrupt]: |
| 24 | s += '\n' |
| 25 | s += ''.join(traceback.format_exc()) |
| 26 | return s |