원클릭으로
error-handling
Design and implement standardized error handling patterns — consistent error
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Design and implement standardized error handling patterns — consistent error
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Consult and write the ARAYA postoffice — the operational-directive channel. Advisory, never a gate: read it at cycle start, append your entry at cycle end, consider its directives, never be blocked by it. Governance acts never travel the postoffice.
Audit and enforce brand compliance across all projects and platforms — logo,
Design REST and GraphQL APIs following OpenAPI 3.1 standards. Produce complete
Connect frontend to backend — type-safe API clients, request/response handling,
Implement authentication and authorization middleware — JWT validation, role-based
Design scalable component architectures — design systems, component libraries,
| name | error-handling |
| description | Design and implement standardized error handling patterns — consistent error |
| governance | Constitution ENG-004: Engineering Excellence & Software Craftsmanship Standard |
Design and implement standardized error handling patterns — consistent error responses, logging, and recovery — so errors are debuggable for developers and safe for users.
Inconsistent error handling leads to information leakage (stack traces to users), lost debugging context (no logs), and confusing API responses. This skill establishes a single error-handling pattern used by every endpoint and service.
At project setup. When an existing project has inconsistent error handling. When adding error tracking/monitoring. Before any API goes to production.
Project language, framework, logging setup, error tracking service.
// src/errors/AppError.ts
export class AppError extends Error {
constructor(
message: string,
public statusCode: number,
public code: string,
public details?: unknown
) {
super(message);
this.name = "AppError";
}
}
export class NotFoundError extends AppError {
constructor(resource: string, id: string) {
super(`${resource} not found`, 404, "NOT_FOUND", { resource, id });
}
}
export class ValidationError extends AppError {
constructor(details: Array<{ field: string; message: string }>) {
super("Validation failed", 400, "VALIDATION_ERROR", details);
}
}
export class UnauthorizedError extends AppError {
constructor(message = "Authentication required") {
super(message, 401, "UNAUTHORIZED");
}
}
export class ForbiddenError extends AppError {
constructor(message = "Insufficient permissions") {
super(message, 403, "FORBIDDEN");
}
}
export class ConflictError extends AppError {
constructor(resource: string) {
super(`${resource} already exists`, 409, "CONFLICT");
}
}
// src/middleware/errorHandler.ts
import { Request, Response, NextFunction } from "express";
import { AppError } from "../errors/AppError";
import { logger } from "../utils/logger";
export function errorHandler(
err: Error,
req: Request,
res: Response,
_next: NextFunction
): void {
// Known application errors
if (err instanceof AppError) {
logger.warn({
message: err.message,
code: err.code,
statusCode: err.statusCode,
path: req.path,
method: req.method,
});
res.status(err.statusCode).json({
error: err.code,
message: err.message,
...(err.details && { details: err.details }),
});
return;
}
// Unknown errors — log fully, return generic
logger.error({
message: err.message,
stack: err.stack,
path: req.path,
method: req.method,
requestId: req.headers["x-request-id"],
});
res.status(500).json({
error: "INTERNAL_ERROR",
message: "An unexpected error occurred",
});
}
{ error: code, message: string, details?: any }