summaryrefslogtreecommitdiff
path: root/yaksh/grader.py
diff options
context:
space:
mode:
authorKing2018-07-12 14:00:59 -0700
committerGitHub2018-07-12 14:00:59 -0700
commit661c9d82bb680e745cc6b498131a0793b954c436 (patch)
tree9982e226f9bf81aaab98d752db3a8aba3de0c631 /yaksh/grader.py
parentf61742f04f417cfb60576f9904afd0dc5c537b3c (diff)
parent714eeb188c67a6b61dfd132f0869e7679d91c8bf (diff)
downloadonline_test-661c9d82bb680e745cc6b498131a0793b954c436.tar.gz
online_test-661c9d82bb680e745cc6b498131a0793b954c436.tar.bz2
online_test-661c9d82bb680e745cc6b498131a0793b954c436.zip
Merge pull request #491 from maheshgudi/catch_compilation_error
Raise appropriate exceptions for C and Java language to the Grader
Diffstat (limited to 'yaksh/grader.py')
-rw-r--r--yaksh/grader.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/yaksh/grader.py b/yaksh/grader.py
index 320e7e7..c1be493 100644
--- a/yaksh/grader.py
+++ b/yaksh/grader.py
@@ -23,6 +23,14 @@ class TimeoutException(Exception):
pass
+class CompilationError(Exception):
+ pass
+
+
+class TestCaseError(Exception):
+ pass
+
+
@contextlib.contextmanager
def change_dir(path):
cur_dir = abspath(dirname(MY_DIR))
@@ -159,10 +167,14 @@ class Grader(object):
line_no = traceback.extract_tb(exc_tb)[-1][1]
if len(tb_list) > 2:
del tb_list[1:3]
+ try:
+ exc_value = str(exc_value)
+ except UnicodeEncodeError:
+ exc_value = unicode(exc_value)
error.append(
prettify_exceptions(
- exc_type.__name__, str(exc_value), "".join(tb_list),
- line_no=line_no
+ exc_type.__name__, exc_value,
+ "".join(tb_list), line_no=line_no
)
)
finally: