MCPcopy
hub / github.com/codebymitch/TitanBot / replyUserError

Function replyUserError

src/utils/errorHandler.js:290–313  ·  view source on GitHub ↗
(interaction, {
    type = ErrorTypes.UNKNOWN,
    message,
    subtype = null,
    ephemeral = true,
    context = {}
} = {})

Source from the content-addressed store, hash-verified

288 * Reply with a typed user-facing error (early-return validation, permission checks, etc.).
289 */
290export async function replyUserError(interaction, {
291 type = ErrorTypes.UNKNOWN,
292 message,
293 subtype = null,
294 ephemeral = true,
295 context = {}
296} = {}) {
297 const errorType = type || ErrorTypes.UNKNOWN;
298 const syntheticError = message
299 ? createError('User error', errorType, message, { expected: true, ...context })
300 : createError('User error', errorType, null, { expected: true, ...context });
301
302 const userMessage = getUserMessage(syntheticError, { subtype, ...context });
303 const { logData, traceId } = buildErrorLogData(interaction, syntheticError, errorType, {
304 ...context,
305 subtype,
306 source: context.source || 'replyUserError'
307 });
308
309 logInteractionError(syntheticError, errorType, logData);
310
311 const embed = buildUserErrorEmbed(errorType, userMessage);
312 return sendErrorResponse(interaction, embed, { ...context, traceId, ephemeral, subtype });
313}
314
315export async function handleInteractionError(interaction, error, context = {}) {
316 const errorType = categorizeError(error);

Callers 15

checkUserPermissionsFunction · 0.90
checkBotPermissionsFunction · 0.90
executeFunction · 0.90
executeFunction · 0.90
handleNameTemplateChangeFunction · 0.90
handleUserLimitChangeFunction · 0.90
handleBitrateChangeFunction · 0.90
handleRemoveTriggerFunction · 0.90
showApplicationSelectorFunction · 0.90
setupCollectorsFunction · 0.90
handleLogChannelFunction · 0.90
handleManagerRoleFunction · 0.90

Calls 6

buildUserErrorEmbedFunction · 0.90
createErrorFunction · 0.85
getUserMessageFunction · 0.85
buildErrorLogDataFunction · 0.85
logInteractionErrorFunction · 0.85
sendErrorResponseFunction · 0.85

Tested by

no test coverage detected