Skip to content

Commit 8242905

Browse files
author
Austin Clements
committed
Print exception tracebacks in debug mode
1 parent 1f0b63a commit 8242905

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

latexrun

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@ import shutil
3333
import curses
3434
import filecmp
3535
import io
36+
import traceback
3637

3738
def debug(string, *args):
3839
if debug.enabled:
3940
print(string.format(*args), file=sys.stderr)
4041
debug.enabled = False
4142

43+
def debug_exc():
44+
if debug.enabled:
45+
traceback.print_exc()
46+
4247
def main():
4348
# Parse command-line
4449
arg_parser = argparse.ArgumentParser(
@@ -122,6 +127,7 @@ def main():
122127
print('error opening {}: {}'.format(e.filename if hasattr(e, 'filename')
123128
else dbpath, e),
124129
file=sys.stderr)
130+
debug_exc()
125131
sys.exit(1)
126132

127133
# Clean
@@ -130,6 +136,7 @@ def main():
130136
db.do_clean(args.obj_dir)
131137
except OSError as e:
132138
print(e, file=sys.stderr)
139+
debug_exc()
133140
sys.exit(1)
134141

135142
# Build
@@ -155,6 +162,7 @@ def main():
155162
status = max(status, 1)
156163
except TaskError as e:
157164
print(str(e), file=sys.stderr)
165+
debug_exc()
158166
status = 1
159167
sys.exit(status)
160168

0 commit comments

Comments
 (0)