judge: friendly error

This commit is contained in:
undefined committed 2021-04-23 12:40:20 +08:00
1 parent c86b063415
commit b406b8989d
4 files changed
+6 -5

No files matched your search

+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "@hydrooj/hydrojudge", "name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js", "bin": "bin/hydrojudge.js",
"version": "2.5.13", "version": "2.5.14",
"main": "package.json", "main": "package.json",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git", "repository": "https://github.com/hydro-dev/Hydro.git",
"dependencies": { "dependencies": {
"@hydrooj/utils": "^1.0.4", "@hydrooj/utils": "^1.0.8",
"adm-zip": "^0.5.5", "adm-zip": "^0.5.5",
"axios": "^0.21.1", "axios": "^0.21.1",
"bson": "^4.3.0", "bson": "^4.3.0",
+2 -1
View File
@@ -180,6 +180,7 @@ async function readAutoCases(folder, { next }, cfg) {
} }
function isValidConfig(config) { function isValidConfig(config) {
if (config.type === 'submit_answer' && !config.outputs.length) throw new FormatError('Problem data not found.');
if (config.count > (getConfig('testcases_max') || 100)) { if (config.count > (getConfig('testcases_max') || 100)) {
throw new FormatError('Too many testcases. Cancelled.'); throw new FormatError('Too many testcases. Cancelled.');
} }
@@ -213,7 +214,7 @@ export default async function readCases(folder: string, cfg: Record<string, any>
} catch (e) { } catch (e) {
throw changeErrorType(e, FormatError); throw changeErrorType(e, FormatError);
} }
if (!(result.outputs || result.subtasks.length)) { if (!(result.outputs?.length || result.subtasks.length)) {
const c = await readAutoCases(folder, args, config); const c = await readAutoCases(folder, args, config);
result.subtasks = c.subtasks; result.subtasks = c.subtasks;
result.count = c.count; result.count = c.count;
+1 -1
View File
@@ -70,7 +70,7 @@ export default async function readYamlCases(cfg: Record<string, any> = {}, check
} }
if (cfg.time) config.time = parseTimeMS(cfg.time); if (cfg.time) config.time = parseTimeMS(cfg.time);
if (cfg.memory) config.memory = parseMemoryMB(cfg.memory); if (cfg.memory) config.memory = parseMemoryMB(cfg.memory);
if (config.type === 'submit_answer' && !cfg.outputs) throw new Error('outputs config not found'); if (config.type === 'submit_answer' && !cfg.outputs?.length) throw new Error('outputs config not found');
return Object.assign(cfg, config); return Object.assign(cfg, config);
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@hydrooj/utils", "name": "@hydrooj/utils",
"version": "1.0.7", "version": "1.0.8",
"description": "hydrooj utils", "description": "hydrooj utils",
"main": "package.json", "main": "package.json",
"repository": "https://github.com/hydro-dev/Hydro.git", "repository": "https://github.com/hydro-dev/Hydro.git",