generated from nhcarrigan/template
feat: build out discord support agent
All checks were successful
Node.js CI / Lint and Test (pull_request) Successful in 1m17s
All checks were successful
Node.js CI / Lint and Test (pull_request) Successful in 1m17s
This commit is contained in:
20
bot/prod/utils/errorHandler.js
Normal file
20
bot/prod/utils/errorHandler.js
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { logger } from "./logger.js";
|
||||
/**
|
||||
* Generates a UUID for an error, sends the error to the logger,
|
||||
* and returns the UUID to be shared with the user.
|
||||
* @param error - The error to log.
|
||||
* @param context - The context in which the error occurred.
|
||||
* @returns A UUID string assigned to the error.
|
||||
*/
|
||||
export const errorHandler = async (error, context) => {
|
||||
const id = crypto.randomUUID();
|
||||
await logger.error(`${context} - Error ID: ${id}`, error instanceof Error
|
||||
? error
|
||||
: new Error(String(error)));
|
||||
return id;
|
||||
};
|
Reference in New Issue
Block a user