vjudge: luogu: parse errormsg

This commit is contained in:
undefined committed 2023-03-02 15:16:11 +08:00
1 parent 09240c6166
commit bce3cba997
1 file changed
+24 -9
+24 -9
View File
@@ -100,15 +100,30 @@ export default class LuoguProvider extends BasicFetcher implements IBasicProvide
lang = lang.slice(0, -2); lang = lang.slice(0, -2);
} }
lang = lang.split('luogu.')[1]; lang = lang.split('luogu.')[1];
const result = await this.post(`/fe/api/problem/submit/${id}${this.account.query || ''}`) try {
.set('referer', `https://www.luogu.com.cn/problem/${id}`) const result = await this.post(`/fe/api/problem/submit/${id}${this.account.query || ''}`)
.send({ .set('referer', `https://www.luogu.com.cn/problem/${id}`)
code, .send({
lang: +lang, code,
enableO2, lang: +lang,
}); enableO2,
logger.info('RecordID:', result.body.rid); });
return result.body.rid; logger.info('RecordID:', result.body.rid);
return result.body.rid;
} catch (e) {
let parsed = e;
if (e.text) {
try {
const message = JSON.parse(e.text).errorMessage;
if (!message) throw e;
parsed = new Error(message);
parsed.stack = e.stack;
} catch (err) {
throw e;
}
}
throw parsed;
}
} }
async waitForSubmission(id: string, next, end) { async waitForSubmission(id: string, next, end) {