Skip to content

Commit

Permalink
fix: time limt 제약 조건 수정
Browse files Browse the repository at this point in the history
- 검사 단위는 1000단위이지만, 그 이하 제한도 가능
  • Loading branch information
cranemont committed Feb 23, 2023
1 parent c17a0dc commit 4f02a2f
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/handler/judge-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ func (r Request) Validate() (*Request, error) {
if r.ProblemId == 0 {
return nil, fmt.Errorf("problemId must not be empty or zero")
}
if r.TimeLimit < 1000 {
return nil, fmt.Errorf("timeLimit must be greater than or equal to 1000")
if r.TimeLimit <= 0 {
return nil, fmt.Errorf("timeLimit must not be empty or less than 0")
}
if r.MemoryLimit <= 0{
return nil, fmt.Errorf("memoryLimit must not be empty and be greater than 0")
if r.MemoryLimit <= 0 {
return nil, fmt.Errorf("memoryLimit must not be empty or less than 0")
}
return &r, nil
}
Expand Down Expand Up @@ -142,18 +142,18 @@ func (j *JudgeHandler) Handle(id string, data []byte) (json.RawMessage, error) {
err := json.Unmarshal(data, &req)
if err != nil {
return nil, &HandlerError{
caller: "handle",
err: fmt.Errorf("%w: %s", ErrValidate, err),
level: logger.ERROR,
caller: "handle",
err: fmt.Errorf("%w: %s", ErrValidate, err),
level: logger.ERROR,
Message: err.Error(),
}
}
validReq, err := req.Validate()
if err != nil {
return nil, &HandlerError{
caller: "request validate",
err: fmt.Errorf("%w: %s", ErrValidate, err),
level: logger.ERROR,
caller: "request validate",
err: fmt.Errorf("%w: %s", ErrValidate, err),
level: logger.ERROR,
Message: err.Error(),
}
}
Expand Down Expand Up @@ -203,9 +203,9 @@ func (j *JudgeHandler) Handle(id string, data []byte) (json.RawMessage, error) {

if testcaseOut.Err != nil {
return nil, &HandlerError{
caller: "handle",
err: fmt.Errorf("%w: %s", ErrTestcaseGet, testcaseOut.Err),
level: logger.ERROR,
caller: "handle",
err: fmt.Errorf("%w: %s", ErrTestcaseGet, testcaseOut.Err),
level: logger.ERROR,
Message: testcaseOut.Err.Error(),
}
}
Expand All @@ -214,26 +214,26 @@ func (j *JudgeHandler) Handle(id string, data []byte) (json.RawMessage, error) {
tc, ok := testcaseOut.Data.(testcase.Testcase)
if !ok {
return nil, &HandlerError{
caller: "handle",
err: fmt.Errorf("%w: Testcase", ErrTypeAssertionFail),
level: logger.ERROR,
caller: "handle",
err: fmt.Errorf("%w: Testcase", ErrTypeAssertionFail),
level: logger.ERROR,
}
}

if compileOut.Err != nil {
// 컴파일러 실행 과정이나 이후 처리 과정에서 오류가 생긴 경우
return nil, &HandlerError{
caller: "handle",
err: fmt.Errorf("%w: %s", ErrSandbox, compileOut.Err),
level: logger.ERROR,
caller: "handle",
err: fmt.Errorf("%w: %s", ErrSandbox, compileOut.Err),
level: logger.ERROR,
}
}
compileResult, ok := compileOut.Data.(sandbox.CompileResult)
if !ok {
return nil, &HandlerError{
caller: "handle",
err: fmt.Errorf("%w: CompileResult", ErrTypeAssertionFail),
level: logger.INFO,
caller: "handle",
err: fmt.Errorf("%w: CompileResult", ErrTypeAssertionFail),
level: logger.INFO,
}
}
if compileResult.ExecResult.ResultCode != sandbox.SUCCESS {
Expand Down

0 comments on commit 4f02a2f

Please sign in to comment.