Skip to content
Back to skills

Architecture

ASecurity

Design of one error model for a service — RFC 9457 problem details, global handler, retries with jitter, circuit breakers and fallbacks. Use when error responses are inconsistent or one dependency takes the service down.

  • 24 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added October 14, 2026
ai-agentsgosqlapibackendsecurity

Works with

  • api

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned November 22, 2026

npx -y skills add andreibesleaga/GABBE --skill architecture --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Architecture?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Architecture
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/andreibesleaga-architecture-f29c4f81/badge)](https://www.skillsdirectory.com/skills/andreibesleaga-architecture-f29c4f81)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: error-handling-strategy
description: Design of one error model for a service — RFC 9457 problem details, global handler, retries with jitter, circuit breakers and fallbacks. Use when error responses are inconsistent or one dependency takes the service down.
triggers: [error handling strategy, problem details, rfc 9457, global exception handler, circuit breaker, retry with backoff]
tags: [architecture]
role: prod-architect, eng-backend
context_cost: low
---
# error-handling-strategy Skill

## Goal
Errors are inevitable. Handling them must be consistent, predictable, and safe.

## Steps
## 1. Unified API Error Format (RFC 9457, which obsoletes RFC 7807)
Never return raw stack traces or ad-hoc JSON strings. Use `Problem Details`:

```json
{
  "type": "https://example.com/probs/out-of-credit",
  "title": "You do not have enough credit.",
  "status": 403,
  "detail": "Current balance is 30, but cost is 50.",
  "instance": "/account/12345/msgs/abc",
  "traceId": "00-5c14d5-..."
}
```

## 2. Centralized Exception Handling
- **Do Not**: Catch exceptions in every controller method.
- **Do**: Use a Global Exception Handler (Middleware / Filter).
  - Map `DomainException` → 422 Unprocessable Entity.
  - Map `NotFoundException` → 404 Not Found.
  - Map `SecurityException` → 401/403.
  - Map `CatchAll` → 500 Internal Server Error (and log trace ID).

## 3. Resilience Patterns
- **Circuit Breaker**: Detect cascading failures. If 50% of requests to Service B fail, open the circuit (fail fast) for 30s.
- **Bulkhead**: Thread pool isolation. Service A crashing shouldn't take down Service B.
- **Retry**: Only retry *transient* errors (Network, 503). Never retry 4xx errors. Backoff: Exponential + Jitter.

## 4. User-Facing Fallbacks
- **Graceful Degradation**: If the "Recommendations" service is down, don't crash the homepage. Show "Popular Items" (static) instead.
- **Friendly Messages**: "Something went wrong" is bad. "We couldn't load your cart, but your items are safe. Try refreshing." is better.

## Constraints
- Never return raw stack traces or ad-hoc JSON error strings.
- Retry only transient errors, never 4xx.

## Output Format
A short design note in the project's architecture docs (`docs/architecture/` by default) with the error format, the exception-to-status mapping, the resilience settings and the fallbacks.

## Limits and safety
- Production responses never carry stack traces, SQL errors or environment values, at any stage; log them with the trace id instead.
- Trace ids are opaque random values: no sequential ids, addresses or readable timestamps.
- Unexpected errors fail closed: 401, 403 or a generic 500, never continue as if nothing happened.
- Authentication errors stay generic ("invalid username or password"); no hints about account state.
- Retries are bounded, with backoff and jitter; an open circuit breaker must not lock out routes it does not protect.

Files in this skill

  • adaptive-architecture.skill.md3.7 KB
  • api-design.skill.md4.7 KB
  • api-standards.skill.md1.7 KB
  • arch-debt.skill.md8.2 KB
  • arch-design.skill.md12.6 KB
  • arch-patterns.skill.md3.9 KB
  • arch-review.skill.md14.1 KB
  • architecture-governance.skill.md3.6 KB
  • attribute-driven-design.skill.md7.5 KB
  • blockchain-dlt.skill.md1.9 KB
  • compatibility-design.skill.md3.6 KB
  • critical-systems-arch.skill.md2 KB
  • design-patterns.skill.md4.3 KB
  • diagramming.skill.md13.9 KB
  • domain-model.skill.md12.1 KB
  • enterprise-migration-scenario.skill.md2 KB
  • enterprise-patterns.skill.md1.9 KB
  • error-handling-strategy.skill.md3.9 KB
  • event-driven-architecture.skill.md1.8 KB
  • event-governance.skill.md3.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.