Revision 826
Added by Aaron Marcuse-Kubitza about 13 years ago
lib/exc.py | ||
---|---|---|
4 | 4 |
import sys |
5 | 5 |
|
6 | 6 |
import strings |
7 |
import term |
|
7 | 8 |
import util |
8 | 9 |
|
9 | 10 |
def raise_(e): raise e |
... | ... | |
22 | 23 |
if with_name: msg = util.type_name(e)+': '+msg |
23 | 24 |
return msg |
24 | 25 |
|
25 |
def print_ex(e, **format): sys.stderr.write('! '+str_(e, **format)) |
|
26 |
def print_ex(e, **format): |
|
27 |
emph = format.pop('emph', True) |
|
28 |
|
|
29 |
msg = str_(e, **format) |
|
30 |
if emph: |
|
31 |
first_line, nl, rest = msg.partition('\n') |
|
32 |
msg = term.error(first_line)+nl+rest |
|
33 |
sys.stderr.write(msg) |
|
26 | 34 |
|
27 | 35 |
class ExTracker: |
28 | 36 |
def __init__(self): |
Also available in: Unified diff
exc.py: Print exceptions with the first line highlighted in red