一键导入
error-handling
Implement consistent error handling across the application. Use when adding try-catch blocks, error boundaries, or custom error classes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Implement consistent error handling across the application. Use when adding try-catch blocks, error boundaries, or custom error classes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when converting architecture plans into implementation phases. Creates independent, bite-sized phase files that can be executed separately.
You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
Extract design assets and metadata from Figma using the Figma REST API. Supports exporting frames/components as images, extracting node metadata, design tokens, and file structure. Use with ai-multimodal skill for comprehensive UI research.
Comprehensive codebase documentation generator following a layered methodology. This skill should be used when scanning and documenting a codebase for the first time, when creating onboarding documentation for new developers, when generating architecture overviews, walkthroughs, and API references. Supports README generation, architecture diagrams, entry point documentation, pattern guides, and edge case documentation.
Generate structured handoff summaries between workflow phases. Use when transitioning between RQPIV phases.
| name | error-handling |
| description | Implement consistent error handling across the application. Use when adding try-catch blocks, error boundaries, or custom error classes. |
Ensure consistent, informative error handling.
Reference: patterns/backend-errors.md
// templates/error-class.ts
export class AppError extends Error {
constructor(
public code: string,
message: string,
public statusCode: number = 500,
public details?: unknown
) {
super(message);
this.name = 'AppError';
}
}
export class ValidationError extends AppError {
constructor(message: string, details?: unknown) {
super('VALIDATION_ERROR', message, 400, details);
}
}
export class NotFoundError extends AppError {
constructor(resource: string) {
super('NOT_FOUND', `${resource} not found`, 404);
}
}
function errorHandler(err, req, res, next) {
logger.error(err);
if (err instanceof AppError) {
return res.status(err.statusCode).json({
error: {
code: err.code,
message: err.message,
details: err.details
}
});
}
return res.status(500).json({
error: {
code: 'INTERNAL_ERROR',
message: 'An unexpected error occurred'
}
});
}
Reference: patterns/frontend-errors.md
class ErrorBoundary extends React.Component {
state = { hasError: false };
static getDerivedStateFromError() {
return { hasError: true };
}
componentDidCatch(error, info) {
logError(error, info);
}
render() {
if (this.state.hasError) {
return <ErrorFallback onReset={() => this.setState({ hasError: false })} />;
}
return this.props.children;
}
}
async function fetchWithError<T>(url: string): Promise<T> {
const response = await fetch(url);
if (!response.ok) {
const error = await response.json();
throw new ApiError(error.code, error.message);
}
return response.json();
}
| Level | Use For |
|---|---|
| error | Exceptions, failures |
| warn | Recoverable issues |
| info | Important events |
| debug | Development info |