mirror of
https://github.com/HeyPuter/puter.git
synced 2026-01-04 04:00:27 -06:00
Report proper error when an operation is invalid
This commit is contained in:
@@ -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 }) => {
|
||||
|
||||
@@ -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) +
|
||||
|
||||
Reference in New Issue
Block a user