File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88import csv
99import os
1010import sys
11+ import textwrap
1112import traceback
1213
1314# Third-party
1415import pandas as pd
16+ from pygments import highlight
17+ from pygments .formatters import TerminalFormatter
18+ from pygments .lexers import PythonTracebackLexer
1519
1620# Add parent directory so shared can be imported
1721sys .path .append (os .path .join (os .path .dirname (__file__ ), ".." ))
@@ -115,7 +119,7 @@ def process_least_language_usage(args, count_data):
115119
116120def process_language_representation (args , count_data ):
117121 """
118- Processing count data: language representation
122+ Processing count data: Language representation
119123 """
120124 LOGGER .info (process_language_representation .__doc__ .strip ())
121125 data = {}
@@ -170,13 +174,22 @@ def main():
170174 LOGGER .info (e .message )
171175 else :
172176 LOGGER .error (e .message )
173- sys .exit (e .code )
177+ sys .exit (e .exit_code )
174178 except SystemExit as e :
175- LOGGER .error (f"System exit with code: { e .code } " )
179+ if e .code != 0 :
180+ LOGGER .error (f"System exit with code: { e .code } " )
176181 sys .exit (e .code )
177182 except KeyboardInterrupt :
178183 LOGGER .info ("(130) Halted via KeyboardInterrupt." )
179184 sys .exit (130 )
180185 except Exception :
181- LOGGER .exception (f"(1) Unhandled exception: { traceback .format_exc ()} " )
186+ traceback_formatted = textwrap .indent (
187+ highlight (
188+ traceback .format_exc (),
189+ PythonTracebackLexer (),
190+ TerminalFormatter (),
191+ ),
192+ " " ,
193+ )
194+ LOGGER .critical (f"(1) Unhandled exception:\n { traceback_formatted } " )
182195 sys .exit (1 )
You can’t perform that action at this time.
0 commit comments