From d091b20b6ac28e26af35b4145955546dfcac27ea Mon Sep 17 00:00:00 2001 From: KernelDeimos <7225168+KernelDeimos@users.noreply.github.com> Date: Tue, 6 Jan 2026 18:48:57 -0500 Subject: [PATCH] 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. --- src/backend/src/api/APIError.js | 8 +++++++- src/backend/src/filesystem/hl_operations/hl_mkdir.js | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/backend/src/api/APIError.js b/src/backend/src/api/APIError.js index 92b44e148..a5b529d6c 100644 --- a/src/backend/src/api/APIError.js +++ b/src/backend/src/api/APIError.js @@ -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, diff --git a/src/backend/src/filesystem/hl_operations/hl_mkdir.js b/src/backend/src/filesystem/hl_operations/hl_mkdir.js index dc1e6ef61..83a29811c 100644 --- a/src/backend/src/filesystem/hl_operations/hl_mkdir.js +++ b/src/backend/src/filesystem/hl_operations/hl_mkdir.js @@ -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 ) {