Custom Errors
While Cluebase automatically catches crashes, you can also enrich your error reporting by throwing or reporting custom error objects with additional context.
Coding Agent Prompt for Custom Errors
Copy & paste this prompt into Cursor, Claude, ChatGPT, Copilot, or Antigravity to set up custom errors and sanitization rules.
Implement custom error classes and data sanitization for Cluebase in this project:
1. Create custom Error classes extending standard JavaScript `Error` (e.g., `class PaymentError extends Error { constructor(message: string, public txId: string) { super(message); this.name = 'PaymentError'; } }`).
2. Throw instances of custom error classes in domain logic so Cluebase captures typed error names and custom metadata.
3. Ensure sensitive PII data (passwords, credit cards, SSNs, auth tokens) is scrubbed before passing context objects to Cluebase.Enriching Errors
When throwing errors that you expect Cluebase to catch, you can attach additional metadata if you are using custom error classes.
class PaymentError extends Error { constructor(message: string, public transactionId: string) { super(message); this.name = 'PaymentError'; }}
// In your codethrow new PaymentError('Transaction failed', 'tx_123');Filtering Sensitive Data
Cluebase automatically redacts common PII (emails, SSNs, phone numbers, and credit-card-shaped digit runs) from error messages, stack traces, URLs, the feedback box, and any additionalContext you pass to reportError(), before anything leaves the browser. No configuration required.
To add your own rules on top (for example, redacting internal account IDs specific to your app), pass a sanitize function to CluebaseProvider:
<CluebaseProvider apiKey={process.env.NEXT_PUBLIC_CLUEBASE_API_KEY ?? ''} sanitize={(text) => text.replace(/acct_[a-zA-Z0-9]+/g, '[redacted-account]')}> {children}</CluebaseProvider>