Skip to content

Commit

Permalink
Report proper error when an operation is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelDeimos committed Apr 16, 2024
1 parent c07d0a2 commit 653898b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/backend/src/api/APIError.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
6 changes: 6 additions & 0 deletions packages/backend/src/filesystem/batch/BatchExecutor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand Down

0 comments on commit 653898b

Please sign in to comment.