Report proper error when an operation is invalid

This commit is contained in:
KernelDeimos
2024-04-15 22:27:03 -04:00
parent c07d0a2bc7
commit 653898b463
2 changed files with 10 additions and 0 deletions

View File

@@ -128,6 +128,10 @@ module.exports = class APIError {
return `Invalid id`;
}
},
'invalid_operation': {
status: 400,
message: ({ operation }) => `Invalid operation: ${quot(operation)}.`,
},
'field_invalid': {
status: 400,
message: ({ key, expected, got }) => {

View File

@@ -85,6 +85,12 @@ class BatchExecutor extends AdvancedBase {
if ( ! x ) throw new Error('no context');
try {
if ( ! command_cls ) {
throw APIError.create('invalid_operation', null, {
operation: op.op,
});
}
if ( file ) workUnit.checkpoint(
'about to run << ' +
(file.originalname ?? file.name) +