ms-tester/pkg/models/result.go
2024-08-25 23:17:47 +05:00

32 lines
824 B
Go

package models
import (
"errors"
"git.sch9.ru/new_gate/ms-tester/internal/lib"
)
type Result int32
const (
NotTested Result = 1 // change only with schema change
Accepted Result = 2
WrongAnswer Result = 3
PresentationError Result = 4
CompilationError Result = 5
MemoryLimitExceeded Result = 6
TimeLimitExceeded Result = 7
RuntimeError Result = 8
SystemFailDuringTesting Result = 9
Testing Result = 10
)
var ErrBadResult = errors.New("bad result")
func (result Result) Valid() error {
switch result {
case NotTested, Accepted, TimeLimitExceeded, MemoryLimitExceeded, CompilationError, SystemFailDuringTesting:
return nil
}
return lib.ServiceError(ErrBadResult, lib.ErrValidationFailed, "bad result")
}