preventing-error-exposure

Transform Prisma errors into user-friendly messages while logging full details server-side.

Updated Nov 21, 2025
One-click install
npx skills add https://github.com/djankies/claude-configs --skill preventing-error-exposure
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: preventing-error-exposure
Source: https://github.com/djankies/claude-configs/tree/main/prisma-6/skills/preventing-error-exposure
Command: npx skills add https://github.com/djankies/claude-configs --skill preventing-error-exposure

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill guides transforming Prisma errors into user-friendly messages for clients while preserving full context in server-side logs.

Core Features & Use Cases

  • Error Sanitization: Map P-codes to generic messages for clients.
  • Server-Side Logging: Capture full error details (stack, query, P-code) for debugging.
  • Operational Resilience: Improve UX while maintaining debuggability.

Quick Start

Implement an error handler that sanitizes Prisma errors before sending responses to clients.

Frequently Asked Questions about preventing-error-exposure

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I hide database errors from API clients when using Prisma?

Transform Prisma errors into user-friendly messages by mapping P-codes to generic responses in your error handler, while logging full details server-side. This prevents exposing sensitive database structure and query information to clients.

Why should I sanitize Prisma errors before sending them to clients?

Exposing raw database errors leaks implementation details, query structure, and schema information that attackers can exploit. Sanitization reduces attack surface while preserving debuggability through server-side logs.

How do I log Prisma errors with full context while showing generic messages to users?

Implement error handling middleware that captures the complete error—stack trace, P-code, query—server-side while sending only a sanitized message to the client. Use correlation IDs to link user-facing messages to detailed logs for support.

Can I handle Prisma error sanitization in try/catch blocks or do I need middleware?

You can sanitize errors in try/catch blocks within individual handlers, but production-ready middleware provides consistent error transformation across all API endpoints, ensuring no sensitive details escape.

What's the best way to map Prisma error codes to user-friendly messages?

Create a P-code mapping table that translates each Prisma error code to a generic message. Enforce this mapping in centralized error handling so all responses follow the same sanitization rules.

Do I lose debugging ability when I sanitize errors for clients?

No. Server-side logging captures full error details independently from client responses. Correlation IDs tie sanitized messages to complete logs, maintaining debuggability without exposing information to users.