From b406b8989dd42f3651fffa7cafb51b6ea35b62ab Mon Sep 17 00:00:00 2001 From: undefined Date: Fri, 23 Apr 2021 12:40:20 +0800 Subject: [PATCH] judge: friendly error --- packages/hydrojudge/package.json | 4 ++-- packages/hydrojudge/src/cases.ts | 3 ++- packages/utils/lib/cases.ts | 2 +- packages/utils/package.json | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index af6c38f21..e038d31b5 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,12 +1,12 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "2.5.13", + "version": "2.5.14", "main": "package.json", "author": "undefined ", "repository": "https://github.com/hydro-dev/Hydro.git", "dependencies": { - "@hydrooj/utils": "^1.0.4", + "@hydrooj/utils": "^1.0.8", "adm-zip": "^0.5.5", "axios": "^0.21.1", "bson": "^4.3.0", diff --git a/packages/hydrojudge/src/cases.ts b/packages/hydrojudge/src/cases.ts index 28f009050..3467b2479 100644 --- a/packages/hydrojudge/src/cases.ts +++ b/packages/hydrojudge/src/cases.ts @@ -180,6 +180,7 @@ async function readAutoCases(folder, { next }, cfg) { } 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)) { throw new FormatError('Too many testcases. Cancelled.'); } @@ -213,7 +214,7 @@ export default async function readCases(folder: string, cfg: Record } catch (e) { throw changeErrorType(e, FormatError); } - if (!(result.outputs || result.subtasks.length)) { + if (!(result.outputs?.length || result.subtasks.length)) { const c = await readAutoCases(folder, args, config); result.subtasks = c.subtasks; result.count = c.count; diff --git a/packages/utils/lib/cases.ts b/packages/utils/lib/cases.ts index 431ef2f1d..bd5845c1b 100644 --- a/packages/utils/lib/cases.ts +++ b/packages/utils/lib/cases.ts @@ -70,7 +70,7 @@ export default async function readYamlCases(cfg: Record = {}, check } if (cfg.time) config.time = parseTimeMS(cfg.time); 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); } diff --git a/packages/utils/package.json b/packages/utils/package.json index 9fb384f3c..0968a23b8 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/utils", - "version": "1.0.7", + "version": "1.0.8", "description": "hydrooj utils", "main": "package.json", "repository": "https://github.com/hydro-dev/Hydro.git",