feat(cmd/joj3): show internal error msg in stage results
This commit is contained in:
parent
132a50833b
commit
3780ae004b
|
@ -1,6 +1,7 @@
|
||||||
package stage
|
package stage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
"github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
|
"github.com/joint-online-judge/JOJ3/cmd/joj3/conf"
|
||||||
|
@ -68,19 +69,24 @@ func generateStages(conf *conf.Conf, group string) ([]stage.Stage, error) {
|
||||||
return stages, nil
|
return stages, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Run(conf *conf.Conf, group string) (
|
func newErrorStageResults(err error) []stage.StageResult {
|
||||||
stageResults []stage.StageResult, forceQuit bool, err error,
|
return []stage.StageResult{
|
||||||
) {
|
|
||||||
stageResultsOnError := []stage.StageResult{
|
|
||||||
{
|
{
|
||||||
Name: "Internal Error",
|
Name: "Internal Error",
|
||||||
Results: []stage.ParserResult{{
|
Results: []stage.ParserResult{{
|
||||||
Score: 0,
|
Score: 0,
|
||||||
Comment: "JOJ3 internal error, check the log in Gitea Actions.",
|
Comment: "JOJ3 internal error, " +
|
||||||
|
"check the log in Gitea Actions.\n" +
|
||||||
|
fmt.Sprintf("Error: `%s`", err),
|
||||||
}},
|
}},
|
||||||
ForceQuit: true,
|
ForceQuit: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Run(conf *conf.Conf, group string) (
|
||||||
|
stageResults []stage.StageResult, forceQuit bool, err error,
|
||||||
|
) {
|
||||||
executors.InitWithConf(
|
executors.InitWithConf(
|
||||||
conf.Stage.SandboxExecServer,
|
conf.Stage.SandboxExecServer,
|
||||||
conf.Stage.SandboxToken,
|
conf.Stage.SandboxToken,
|
||||||
|
@ -88,7 +94,7 @@ func Run(conf *conf.Conf, group string) (
|
||||||
stages, err := generateStages(conf, group)
|
stages, err := generateStages(conf, group)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("generate stages", "error", err)
|
slog.Error("generate stages", "error", err)
|
||||||
stageResults = stageResultsOnError
|
stageResults = newErrorStageResults(err)
|
||||||
forceQuit = true
|
forceQuit = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -96,7 +102,7 @@ func Run(conf *conf.Conf, group string) (
|
||||||
stageResults, forceQuit, err = stage.Run(stages)
|
stageResults, forceQuit, err = stage.Run(stages)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("run stages", "error", err)
|
slog.Error("run stages", "error", err)
|
||||||
stageResults = stageResultsOnError
|
stageResults = newErrorStageResults(err)
|
||||||
forceQuit = true
|
forceQuit = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user