summaryrefslogtreecommitdiff
path: root/python/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/common.py')
-rw-r--r--python/common.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/python/common.py b/python/common.py
index 5ce2eb3..7d4eaab 100644
--- a/python/common.py
+++ b/python/common.py
@@ -7,6 +7,11 @@ hint_type = {
'no_hint': Hint('no_hint'),
'test_results': Hint('test_results'),
'syntax_error': Hint('syntax_error'),
+ 'name_error': Hint('name_error'),
+ 'type_error': Hint('name'),
+ 'error': Hint('error'),
+ 'eof_error': Hint('eof_error'),
+ 'timed_out': Hint('timed_out'),
}
def hint(python, program):
@@ -17,3 +22,17 @@ def hint(python, program):
error_msg = '{}{}^\n{}'.format(ex.text, ' '*(ex.offset-1), ex.msg)
return [{'id': 'syntax_error', 'args': {'lineno': ex.lineno, 'message': error_msg}}]
return []
+
+
+def exception(exc_string):
+ if exc_string:
+ if 'EOFError' in exc_string:
+ return [{'id':'eof_error'}]
+ if 'timed out' in exc:
+ return [{'id':'timed_out'}]
+ if 'NameError' in exc:
+ return [{'id':'name_error', 'args': {'message': exc}}]
+ elif 'TypeError' in exc:
+ return [{'id':'type_error', 'args': {'message': exc}}]
+ else:
+ return [{'id':'error', 'args': {'message': exc}}]