mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 08:33:36 +00:00
refactor: centralize error handling utilities across route modules
- Introduced a new common utility module for error handling, providing consistent methods for retrieving error messages and logging errors. - Updated individual route modules to utilize the shared error handling functions, reducing code duplication and improving maintainability. - Ensured all routes now log errors in a standardized format, enhancing debugging and monitoring capabilities.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import { createLogger } from "../../lib/logger.js";
|
||||
import { getErrorMessage as getErrorMessageShared } from "../common.js";
|
||||
|
||||
const logger = createLogger("SpecRegeneration");
|
||||
|
||||
@@ -65,9 +66,7 @@ export function logError(error: unknown, context: string): void {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get error message from error object
|
||||
*/
|
||||
export function getErrorMessage(error: unknown): string {
|
||||
return error instanceof Error ? error.message : "Unknown error";
|
||||
}
|
||||
import { getErrorMessage as getErrorMessageShared } from "../common.js";
|
||||
|
||||
// Re-export shared utility
|
||||
export { getErrorMessageShared as getErrorMessage };
|
||||
|
||||
Reference in New Issue
Block a user