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

Function categorizeError

src/utils/errorHandler.js:40–77  ·  view source on GitHub ↗
(error)

Source from the content-addressed store, hash-verified

38}
39
40export function categorizeError(error) {
41 if (error instanceof TitanBotError) {
42 return error.type;
43 }
44
45 const message = error.message?.toLowerCase() || '';
46 const code = error.code;
47
48 if (code >= 10000 && code < 20000) {
49 return ErrorTypes.DISCORD_API;
50 }
51
52 if (message.includes('rate limit') || code === 50001) {
53 return ErrorTypes.RATE_LIMIT;
54 }
55
56 if (message.includes('permission') || message.includes('missing') || code === 50013) {
57 return ErrorTypes.PERMISSION;
58 }
59
60 if (message.includes('database') || message.includes('connection') || message.includes('timeout')) {
61 return ErrorTypes.DATABASE;
62 }
63
64 if (message.includes('network') || message.includes('fetch') || message.includes('enotconn')) {
65 return ErrorTypes.NETWORK;
66 }
67
68 if (message.includes('config') || message.includes('not found') || message.includes('invalid')) {
69 return ErrorTypes.CONFIGURATION;
70 }
71
72 if (message.includes('validation') || message.includes('invalid') || message.includes('required')) {
73 return ErrorTypes.VALIDATION;
74 }
75
76 return ErrorTypes.UNKNOWN;
77}
78
79const UserMessages = {
80 [ErrorTypes.VALIDATION]: {

Callers 2

getUserMessageFunction · 0.85
handleInteractionErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected