mirror of
https://github.com/HeyPuter/puter.git
synced 2026-09-26 23:26:04 +00:00
dev: improve error message for dest_does_not_exist
This error message was ambiguous for mkdir operations where a shortcut target is specified for hl_mkdir. The message looks like it's referring to the shortcut target but really it is referring to the parent directory for the new directory that will be created.
This commit is contained in:
@@ -121,7 +121,13 @@ class APIError {
|
||||
},
|
||||
'dest_does_not_exist': {
|
||||
status: 422,
|
||||
message: 'Destination was not found.',
|
||||
message: ({ what_dest }) => {
|
||||
if ( ! what_dest ) {
|
||||
return 'Destination was not found.';
|
||||
}
|
||||
|
||||
return `Destination of ${quot(what_dest)} was not found.`;
|
||||
},
|
||||
},
|
||||
'source_does_not_exist': {
|
||||
status: 404,
|
||||
|
||||
@@ -480,7 +480,7 @@ class HLMkdir extends HLFilesystemOperation {
|
||||
dir.get_selector_of_type(NodePathSelector);
|
||||
|
||||
if ( ! maybe_path_selector ) {
|
||||
throw APIError.create('dest_does_not_exist');
|
||||
throw APIError.create('dest_does_not_exist', null, { what_dest: 'path from selector' });
|
||||
}
|
||||
|
||||
const path = maybe_path_selector.value;
|
||||
@@ -498,7 +498,12 @@ class HLMkdir extends HLFilesystemOperation {
|
||||
|
||||
async _get_existing_top_parent ({ top_parent }) {
|
||||
if ( ! await top_parent.exists() ) {
|
||||
throw APIError.create('dest_does_not_exist');
|
||||
throw APIError.create('dest_does_not_exist', null, {
|
||||
// This seems verbose, but is necessary information when creating
|
||||
// shortcuts, otherwise the developer doesn't know if we're talking
|
||||
// about the shortcut's target directory or this parent directory.
|
||||
what_dest: 'parent directory of the new directory being created',
|
||||
});
|
||||
}
|
||||
|
||||
if ( ! top_parent.entry.is_dir ) {
|
||||
|
||||
Reference in New Issue
Block a user