Skip to content

Send a body with the 400 from shell/trash-item - #139

Open
sadiqk2 wants to merge 1 commit into
NativePHP:mainfrom
sadiqk2:fix/trash-item-empty-json-response
Open

Send a body with the 400 from shell/trash-item#139
sadiqk2 wants to merge 1 commit into
NativePHP:mainfrom
sadiqk2:fix/trash-item-empty-json-response

Conversation

@sadiqk2

@sadiqk2 sadiqk2 commented Aug 14, 2026

Copy link
Copy Markdown
try {
    await shell.trashItem(path);
    res.sendStatus(200);
} catch {
    res.status(400).json();
}

res.json() with no argument throws in express, so the caught failure becomes an unhandled error inside the handler rather than the 400 the code intends. The caller sees a hung or 500 request instead of a clean failure.

Passing the message through also means the caller learns why — trashing fails for ordinary reasons (a permission problem, a path on a volume without a trash) and PHP-side Shell::trash() currently has no way to report which.

res.json() with no argument throws inside express, so a trashItem() failure that
was caught turns into an unhandled error in the handler instead of the intended
400. Passing the message through also tells the caller why it failed.
@sadiqk2

sadiqk2 commented Aug 17, 2026

Copy link
Copy Markdown
Author

@simonhamp kindly review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant