When designing and implementing web interfaces to ensure they are usable by everyone.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
When designing how a system recovers from and reports failures.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
설치 방법 보기설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.
Uncaught exceptions crash servers. Leaked errors expose vulnerabilities. This skill creates a central, robust pipeline for capturing, categorizing, logging, and responding to failures without leaking sensitive data, ensuring system resilience and debugging capability.
try/catch blocksAppError class with statusCode, isOperational flag, and metadatacatch(e) {})throw "User not found" (throw Error objects always)catch(e) {} with no logging or action{ error: true } payloadtype, title, detail, statuscatch(e) {} blocks with no actionstatusCode, message, isOperational flag, and optional context❌ Anti-pattern (Silent catching, leaking details, wrong status):
app.get('/users/:id', async (req, res) => {
try {
const user = await db.query(`SELECT * FROM users WHERE id = ${req.params.id}`);
res.json(user);
} catch(e) {
// ANTI-PATTERN: silent catch
res.json({ status: 'error', message: e.message }); // ANTI-PATTERN: 200 OK
// ANTI-PATTERN: leaking SQL details
}
});
✅ Correct pattern (Centralized, sanitized, proper codes):
// 1. Define error class
class AppError extends Error {
constructor(statusCode, message, isOperational = true) {
super(message);
this.statusCode = statusCode;
this.isOperational = isOperational;
}
}
// 2. Route handler
app.get('/users/:id', async (req, res, next) => {
try {
const user = await db.query('SELECT * FROM users WHERE id = ?', [req.params.id]);
if (!user) {
return next(new AppError(404, 'User not found'));
}
res.json(user);
} catch (err) {
next(err); // Pass to global handler
}
});
// 3. Global error middleware
app.use((err, req, res, next) => {
// Log with context
logger[err.isOperational ? 'warn' : 'error']({
message: err.message,
statusCode: err.statusCode,
stack: err.stack,
requestId: req.id,
userId: req.user?.id
});
// Crash on programmer error
if (!err.isOperational) {
process.exit(1);
}
// Sanitized response
res.status(err.statusCode || 500).json({
type: 'https://api.example.com/errors/app-error',
title: err.statusCode === 404 ? 'Not Found' : 'Server Error',
detail: err.isOperational ? err.message : 'Internal server error',
status: err.statusCode || 500
});
});
아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.
로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.
아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.
When designing and implementing web interfaces to ensure they are usable by everyone.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
When creating or extending an HTTP API for client consumption.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
When improving read performance and reducing database load.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
When configuring automated build, test, and deployment workflows for a repository.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
When asynchronously reviewing peer code before merging into the main branch.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
When addressing slow application endpoints, high database CPU usage, or standardizing data access patterns.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.