Skip to content

Comments

feat(dev): use toast error messages for failed DevTool actions#146

Merged
BastiDood merged 5 commits intomainfrom
basti/devtool-toasts
Feb 19, 2026
Merged

feat(dev): use toast error messages for failed DevTool actions#146
BastiDood merged 5 commits intomainfrom
basti/devtool-toasts

Conversation

@BastiDood
Copy link
Owner

This PR adds granular error handling to all developer tool form actions (closes #143). Previously, DevTool failures threw opaque error() responses; now they use fail() with specific HTTP status codes (404, 422), enabling the client-side Svelte forms to display context-aware toast messages per failure type.

Also fixes a cyclical type reference in app.d.ts by importing from specific schema submodules instead of the barrel export.

Implementation Notes

  • fail() over error(): Dev tool actions now return fail(status) or fail(status, message) instead of throwing error(status). This lets use:enhance callbacks discriminate on result.status and show targeted toasts.
  • Database error discrimination: The role action catches DrizzleQueryError wrapping DatabaseError with code 23503 (foreign key violation) to surface a "Lab not found" toast when an invalid lab ID is provided.
  • Valibot validation errors: All dev tool actions now catch ValiError and return fail(422) for malformed input, surfaced as "Invalid input" toasts on the client.
  • Email action 404s: Each email event branch individually catches AssertionError from getUserNameByEmail/getLabById and returns fail(404, descriptiveMessage), allowing the client to show the specific missing entity in the toast.
  • Dummy user creation: Wrapped in a REPEATABLE READ transaction for atomicity of user upsert + session creation/swap.

Test Cases

  • Role switcher: switching to a non-existent lab shows "Lab not found" toast
  • Role switcher: submitting invalid form data shows "Invalid role input" toast
  • Dummy user creator: submitting invalid form data shows "Invalid dummy user input" toast
  • User switcher: switching to a non-existent email shows "User email not found" toast
  • User switcher: submitting invalid form data shows "Invalid user email input" toast
  • Email dispatcher: referencing a non-existent lab/user shows specific 404 toast
  • Email dispatcher: submitting invalid payload shows "Invalid email event payload" toast
  • All dev tools: successful actions still work as before

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

@BastiDood BastiDood merged commit 0e3ac41 into main Feb 19, 2026
1 check passed
@BastiDood BastiDood deleted the basti/devtool-toasts branch February 19, 2026 22:49
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.

DevTools should gracefully fail if provided arguments are invalid

1 participant