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.
日本語の概要は準備中です。原文の説明を表示しています。