Error Handling & Validation

A shared folder with AI prompts and code snippets

From workspace: Bolt

Team: Main

Total snippets: 7

Bolt

Error Handling & Validation

7 snippets

Add Try Catch Blocks to Async Code

Wrap all async functions in try/catch blocks and display error messages.

Wrap all async functions in this file with try/catch. Include: – Show user-friendly error message – Log technical error to console – Avoid breaking app flow

Add 404 Page

Create a custom 404 page for unknown routes.

Create a 404 page for when users navigate to unknown routes. Include: – Friendly error message – Link to return to homepage – Responsive and styled layout

Add Error Toast Notifications

Show toast notifications when API or form errors occur.

Add toast notifications that appear on error events. Include: – Show user-friendly messages – Auto-hide after 5 seconds – Allow manual dismiss

Add Empty State Handling

Show appropriate UI when lists or queries return no results.

Show a clean empty state UI when data is unavailable. Include: – Icon and message – Optional button to add new item – Avoid layout shift or broken components

Add Global Error Boundary

Add a global error boundary to catch UI rendering crashes.

Add a global error boundary component to catch UI crashes. Include: – Show fallback message – Log error for debugging – Allow retry option if possible

Validate Backend API Input

Add backend-side validation for required and structured data.

Add backend validation for API inputs. Include: – Check required fields – Enforce data types – Return structured error messages

Add Form Field Validation

Add frontend validation to all form inputs with inline error messages.

Add form validation to all inputs on this form. Include: – Show inline error messages – Email must be valid format – Required fields must be filled