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

Function ensureTypedServiceError

src/utils/serviceErrorBoundary.js:47–80  ·  view source on GitHub ↗
(error, options = {})

Source from the content-addressed store, hash-verified

45}
46
47export function ensureTypedServiceError(error, options = {}) {
48 if (error instanceof TitanBotError) {
49 return error;
50 }
51
52 const context = normalizeBoundaryContext(options.context);
53 const fallbackType = options.type || ErrorTypes.UNKNOWN;
54 const type = inferErrorType(error, fallbackType);
55 const service = options.service || 'unknown_service';
56 const operation = options.operation || 'unknown_operation';
57 const errorCode = resolveErrorCode({
58 error,
59 errorType: type,
60 context: {
61 errorCode: options.errorCode || `${service}.${operation}.failed`
62 }
63 });
64 const errorMetadata = getErrorMetadata(errorCode);
65 const message = options.message || `${service}.${operation} failed`;
66 const userMessage = options.userMessage || 'Something went wrong while processing your request.';
67
68 return createError(message, type, userMessage, {
69 ...context,
70 service,
71 operation,
72 errorCode,
73 remediationHint: errorMetadata.remediation,
74 severity: errorMetadata.severity,
75 retryable: errorMetadata.retryable,
76 originalErrorMessage: error?.message || String(error),
77 originalErrorName: error?.name || 'Error',
78 expected: false
79 });
80}
81
82export function wrapServiceBoundary(fn, options = {}) {
83 return function wrappedServiceBoundary(...args) {

Callers 12

verifyUserFunction · 0.90
autoVerifyOnJoinFunction · 0.90
removeVerificationFunction · 0.90
getUserTicketCountFunction · 0.90
createTicketFunction · 0.90
closeTicketFunction · 0.90
claimTicketFunction · 0.90
reopenTicketFunction · 0.90
deleteTicketFunction · 0.90
unclaimTicketFunction · 0.90
updateTicketPriorityFunction · 0.90
wrapServiceBoundaryFunction · 0.85

Calls 5

resolveErrorCodeFunction · 0.90
getErrorMetadataFunction · 0.90
createErrorFunction · 0.90
normalizeBoundaryContextFunction · 0.85
inferErrorTypeFunction · 0.85

Tested by

no test coverage detected