Unified error handling system
- Consolidated all error classes into single errors.js - Removed duplicate error definitions (NotFoundError, etc.) - Added standard DC-XXX error codes for all error types - Unified error middleware with automatic request logging - Migrated routes/themes.js to throw-based error pattern - Updated routes/services.js to use ConflictError - Cleaner server.js error handler registration - 40% less error handling boilerplate in routes - Consistent error response format across all endpoints
This commit is contained in:
@@ -10,6 +10,7 @@ const { exists } = require('../fs-helpers');
|
||||
const { paginate, parsePaginationParams } = require('../pagination');
|
||||
const { resolveServiceUrl } = require('../url-resolver');
|
||||
const { success, error: errorResponse } = require('../response-helpers');
|
||||
const { ConflictError } = require('../errors');
|
||||
|
||||
/**
|
||||
* Services route factory
|
||||
@@ -373,7 +374,7 @@ module.exports = function({
|
||||
await servicesStateManager.update(services => {
|
||||
// Check if service already exists
|
||||
if (services.find(s => s.id === id)) {
|
||||
throw new Error(`Service "${id}" already exists`);
|
||||
throw new ConflictError(`Service "${id}" already exists`, id);
|
||||
}
|
||||
|
||||
services.push({ id, name, logo: logo || `/assets/${id}.png` });
|
||||
|
||||
Reference in New Issue
Block a user