feat: return error on unmarshal failed

This commit is contained in:
张泊明518370910136 2024-10-04 09:17:36 -04:00
parent b95f2187e3
commit 0cf87fa332
GPG Key ID: D47306D7062CDA9D

View File

@ -50,7 +50,16 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
continue
}
var record Record
_ = json.Unmarshal([]byte(line), &record)
err := json.Unmarshal([]byte(line), &record)
if err != nil {
return stage.ParserResult{
Score: 0,
Comment: fmt.Sprintf(
"Unexpected parser error: %s.",
err,
),
}
}
records = append(records, record)
}
comment, score, err := GetResult(records, conf)