bb-tech-error-handling

Standardize Express error handling with custom classes and sanitized client responses.

Updated Apr 16, 2026
One-click install
npx skills add https://github.com/valentinmathey/Skills-Back-Automation --skill bb-tech-error-handling
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bb-tech-error-handling
Source: https://github.com/valentinmathey/Skills-Back-Automation/tree/main/skills/bb-tech-error-handling
Command: npx skills add https://github.com/valentinmathey/Skills-Back-Automation --skill bb-tech-error-handling

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Manejo robusto de errores inesperados, limpieza de logs en el backend y sanitización para respuestas al cliente.

Core Features & Use Cases

  • Seguridad en Stack Traces: Nunca exponer trazas ni mensajes crudos al cliente, salvo en entornos dev.
  • Clases de Error Customizadas: Las validaciones deben usar clases semánticas (p.ej. NotFoundError, BusinessLogicError, UnauthorizedError) mapeadas a códigos de estado HTTP.
  • Logger Centralizado + Sanitización: Si un proceso falla, el error técnico completo debe registrarse en consola y el cliente debe recibir una respuesta controlada y genérica.

Quick Start

Configure your Express services to catch exceptions, throw NotFoundError or BusinessLogicError, and respond with sanitized, user-friendly error messages.

Frequently Asked Questions about bb-tech-error-handling

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

FAQPage Schema
How do I prevent exposing stack traces in Express API error responses?

Preventing stack trace exposure in Express API responses requires backend error sanitization. This technique intercepts raw technical errors via middleware, logs them centrally for debugging, and returns generic, user-friendly messages to the client instead of sensitive data.

What is the best way to structure custom error classes for an Express backend?

Structuring custom error classes for an Express backend involves creating semantic error types like NotFoundError or BusinessLogicError. These custom classes map specific application failures directly to appropriate HTTP status codes for consistent API responses.

How does centralized logging work with sanitized client messages in TypeScript?

Centralized logging with sanitized client messages in TypeScript separates technical logs from user output. When a process fails, the full technical error is logged to the console, while the API responds with a controlled, generic message to prevent data leakage.

Does this error handling approach support development environments differently?

Yes, this error handling approach supports development environments differently by controlling stack trace visibility. Raw error traces and messages are hidden from clients except in development environments, ensuring production security while maintaining developer debuggability.

Why do my API endpoints return raw internal error messages to users?

API endpoints return raw internal error messages to users when lacking a centralized error handling middleware. Implementing a sanitization layer catches unexpected failures, logs the technical details safely, and maps them to controlled, generic client responses.