error-contract
БесплатноБез исполняемых скриптовНе проверенStandardized error response handling between frontend and backend. Covers error structure, status codes, and consistent error handling. USE WHEN: user asks…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
Error Contract - Quick Reference
When NOT to Use This Skill
- Logging configuration - Use logging skills
- Exception handling patterns - Use language-specific skills
- Security error handling - Use security skills
Deep Knowledge: Use
mcp__documentation__fetch_docsfor framework-specific error handling patterns.
Standard Error Response Structure
RFC 7807 (Problem Details)
{
"type": "https://api.example.com/errors/validation",
"title": "Validation Error",
"status": 400,
"detail": "The request body contains invalid data",
"instance": "/users/123",
"errors": [
{
"field": "email",
"message": "Invalid email format",
"code": "INVALID_FORMAT"
}
],
"traceId": "abc123-def456"
}
Simple Error Structure
{
"error": {
"code": "VALIDATION_ERROR",
"message": "The request body contains invalid data",
"details": [
{
"field": "email",
"message": "Invalid email format"
}
]
}
}
OpenAPI Error Definition
components:
schemas:
Error:
type: object
required:
- code
- message
properties:
code:
type: string
description: Machine-readable error code
example: "VALIDATION_ERROR"
message:
type: string
description: Human-readable error message
example: "Invalid request data"
details:
type: array
items:
$ref: '#/components/schemas/ErrorDetail'
traceId:
type: string
description: Request trace ID for debugging
example: "abc123-def456"
ErrorDetail:
type: object
properties:
field:
type: string
example: "email"
message:
type: string
example: "Invalid email format"
code:
type: string
example: "INVALID_FORMAT"
responses:
BadRequest:
description: Invalid request data
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
code: "VALIDATION_ERROR"
message: "Invalid request data"
details:
- field: "email"
message: "Invalid email format"
Unauthorized:
description: Authentication required
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
code: "UNAUTHORIZED"
message: "Authentication required"
NotFound:
description: Resource not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
code: "NOT_FOUND"
message: "User not found"
Status Code Mapping
| Status | Code Constant | When to Use |
|---|---|---|
| 400 | VALIDATION_ERROR |
Invalid request body/params |
| 401 | UNAUTHORIZED |
Missing or invalid auth |
| 403 | FORBIDDEN |
Valid auth, insufficient permissions |
| 404 | NOT_FOUND |
Resource doesn't exist |
| 409 | CONFLICT |
Duplicate resource, state conflict |
| 422 | UNPROCESSABLE_ENTITY |
Semantic validation failure |
| 429 | TOO_MANY_REQUESTS |
Rate limit exceeded |
| 500 | INTERNAL_ERROR |
Unexpected server error |
| 503 | SERVICE_UNAVAILABLE |
Temporary unavailability |
Frontend Error Handling
TypeScript Error Types
// Base error interface matching backend
interface ApiError {
code: string;
message: string;
details?: ErrorDetail[];
traceId?: string;
}
interface ErrorDetail {
field: string;
message: string;
code?: string;
}
// Error class for typed handling
class ApiRequestError extends Error {
constructor(
public readonly code: string,
message: string,
public readonly status: number,
public readonly details?: ErrorDetail[],
public readonly traceId?: string,
) {
super(message);
this.name = 'ApiRequestError';
}
static fromResponse(status: number, body: ApiError): ApiRequestError {
return new ApiRequestError(
body.code,
body.message,
status,
body.details,
body.traceId,
);
}
isValidationError(): boolean {
return this.code === 'VALIDATION_ERROR';
}
isNotFound(): boolean {
return this.code === 'NOT_FOUND';
}
isUnauthorized(): boolean {
return this.code === 'UNAUTHORIZED';
}
getFieldError(field: string): string | undefined {
return this.details?.find(d => d.field === field)?.message;
}
}
Fetch Wrapper with Error Handling
async function fetchApi<T>(
url: string,
options?: RequestInit,
): Promise<T> {
const response = await fetch(url, {
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers,
},
});
if (!response.ok) {
const errorBody: ApiError = await re
Установить error-contract в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobBashFAQ
Что делает скилл error-contract?
Standardized error response handling between frontend and backend. Covers error structure, status codes, and consistent error handling. USE WHEN: user asks about "error handling", "API errors", "error response format", "status codes", "error messages", "validation errors" DO NOT USE FOR: logging - use logging skills, exception handling - use language-specific skills
Как установить скилл error-contract?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл error-contract запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic