BoilerPrompt
Lovable

Lovable prompt to add error handling

Point this at an existing Lovable project and it sweeps the layers where failures currently vanish: thrown renders, ignored Supabase error objects, unvalidated forms, and edge functions that die silently. You get an error boundary, retryable inline states for reads, toasts for writes, and a changed-file list so you can review the sweep instead of trusting it.

Last updated

Prompt
Audit this app for unhandled failures and add consistent error handling. Do not change feature behavior or visual design while doing it.

Cover these layers:
- React: an error boundary around routed page content that shows a plain fallback with a reload button instead of a white screen. The shell and navigation stay usable when one page throws.
- Supabase queries: supabase-js returns { data, error } rather than throwing, so check the error object on every select, insert, update, and delete. Reads render an inline error with a retry button in place of the data; writes show a toast with a short human message and preserve whatever the user typed.
- Forms: validate required fields and formats before submit with field-level messages; the database rejecting bad input must never be the only feedback.
- Edge functions: wrap handlers so unexpected exceptions return JSON with a 500 instead of an empty response, and log enough context to find the failure later.
- Network: word the message differently for offline or timeout versus a server error, and never surface a raw error object, stack trace, or Postgres error code to the user.

Conventions: one shared toast helper and one shared error-to-message mapper so wording stays consistent across the app.

When finished, list every file you changed with one line on what is now handled there, plus any call sites that still swallow errors silently so I can decide about those separately.

Same task in other tools

Questions about this prompt

Will one prompt really cover the whole app?

On a small project, usually. On a larger one Lovable tends to concentrate on recently edited screens, which is why the prompt demands a changed-file list plus the call sites it skipped. Re-run it scoped to one page at a time if the leftovers list is long.

It keeps restyling components while adding error states. How do I stop that?

The instruction to leave visual design alone is already in the prompt, so when it drifts, name the component and reply that the styling must revert while the handling stays. Follow-ups that reference the original constraint work better than repeating the whole request.

Why were so many failures silent in the first place?

supabase-js returns an error object instead of throwing, so code that ignores the second half of { data, error } fails without a trace. Generated code often does this, which is exactly the pattern this prompt hunts down.

Related prompts