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:
KernelDeimos
2026-01-06 19:09:48 -05:00
committed by Eric Dubé
parent 630f76d8b4
commit d091b20b6a
2 changed files with 14 additions and 3 deletions
+7 -1
View File
@@ -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 ) {