Skip to content

Commit

Permalink
[#48]feat: input error
Browse files Browse the repository at this point in the history
  • Loading branch information
ujkkk committed Nov 12, 2024
1 parent 1f0042d commit 116a6b0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/route/execute/service/execute_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def execute_code(source_code: str, user_input: str):
# 프로세스 실행 중 비정상 종료
except subprocess.CalledProcessError as e:
line_number = _get_error_line_number(e.stderr)
if _is_input_missmatch(e.stderr):
raise CodeExecuteError(ErrorEnum.INPUT_SIZE_MATCHING_ERROR)

raise CodeSyntaxError(ErrorEnum.CODE_SYNTAX_ERROR, {"lineNumber": line_number, "errorMessage": e.stderr})

except subprocess.TimeoutExpired as e:
Expand All @@ -39,6 +42,11 @@ def execute_code(source_code: str, user_input: str):
raise TaskFailException(ErrorEnum.CODE_EXEC_SERVER_ERROR, e.args[0])


def _is_input_missmatch(error_msg):
if "EOF when reading" in error_msg:
return True
return False

def _get_error_line_number(error_msg):
matches = re.findall(r'line (\d+), in', error_msg)
if matches:
Expand Down

0 comments on commit 116a6b0

Please sign in to comment.