MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / withErrorHandling

Function withErrorHandling

src/utils/errorHandler.js:326–345  ·  view source on GitHub ↗
(fn, context = {})

Source from the content-addressed store, hash-verified

324}
325
326export function withErrorHandling(fn, context = {}) {
327 return async (...args) => {
328 try {
329 return await fn(...args);
330 } catch (error) {
331 const interaction = args.find((arg) =>
332 arg && typeof arg === 'object' &&
333 (arg.isCommand || arg.isButton || arg.isModalSubmit || arg.isStringSelectMenu || arg.isChatInputCommand || arg._isPrefixCommand)
334 );
335
336 if (interaction) {
337 await handleInteractionError(interaction, error, context);
338 } else {
339 logger.error('Error in non-interaction context:', error);
340 }
341
342 return null;
343 }
344 };
345}
346
347export function createError(message, type = ErrorTypes.UNKNOWN, userMessage = null, context = {}) {
348 const normalizedContext = {

Callers 15

app-admin.jsFile · 0.90
apply.jsFile · 0.90
withdraw.jsFile · 0.90
mine.jsFile · 0.90
deposit.jsFile · 0.90
balance.jsFile · 0.90
work.jsFile · 0.90
crime.jsFile · 0.90
gamble.jsFile · 0.90
inventory.jsFile · 0.90
fish.jsFile · 0.90
rob.jsFile · 0.90

Calls 1

handleInteractionErrorFunction · 0.85

Tested by

no test coverage detected