بنقرة واحدة
api-error-handling
Standardized error format, error code clusters, and API client usage for consistent error handling.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Standardized error format, error code clusters, and API client usage for consistent error handling.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | api-error-handling |
| description | Standardized error format, error code clusters, and API client usage for consistent error handling. |
This skill ensures consistent error handling between the frontend and backend. It defines a standardized error response format and a system of error code clusters to categorize and handle issues effectively.
All error responses from the backend (BFF or mock) MUST follow this format:
{
"error": "Human-readable error message",
"code": "CATEGORY_DESCRIPTION"
}
Error codes follow the format [CATEGORY]_[DESCRIPTION]. Use the ErrorCode constant from @/http/codes for comparison.
| Category | Prefix | Description | Examples |
|---|---|---|---|
| System | SYS_ | Infrastructural or unexpected errors | SYS_SERVER_ERROR, SYS_TIMEOUT |
| Auth | AUTH_ | Authentication and authorization issues | AUTH_TOKEN_EXPIRED, AUTH_FORBIDDEN |
| Validation | VAL_ | Input parameter or schema validation | VAL_MISSING_FIELD, VAL_INVALID_PARAMS |
| Business | BIZ_ | Business logic constraints | BIZ_RESOURCE_NOT_FOUND, BIZ_ALREADY_EXISTS |
ErrorCode from @/http/codes to check for specific error types.HttpClient and passed to handleError (toast notification, etc.).skipErrorHandler: true in the request configuration to handle errors manually within components or hooks.try {
await request.post('/resource', data, { skipErrorHandler: true });
} catch (error) {
if (error.code === ErrorCode.BIZ_ALREADY_EXISTS) {
// Custom logic
}
}
[!IMPORTANT] Consistency: Ensure that backend error codes align with the frontend constants to maintain a robust UX.
ZGO API development standards including pagination, error handling, and RESTful design
Test patterns, mocking strategies, and organization best practices
Specifications for Zustand stores, React Query hooks, and the Service-Hook-Type pattern with optimistic updates.
Strict rules for environment variable management using Zod validation and src/config/env.ts.
Guidelines for managing internationalization (i18n) in the project using next-intl and unified translation patterns.
High-level overview of project structure, mock API architecture, and authentication flow.