MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / getErrorMessage

Function getErrorMessage

apps/api/src/lib/errors/errors.utils.ts:10–32  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

8 * pattern. Preserves cause chains by appending `cause.message` when present.
9 */
10export const getErrorMessage = (error: unknown): string => {
11 if (error instanceof Error) {
12 if (error.cause instanceof Error && error.cause.message !== "") {
13 return `${error.message} (caused by: ${error.cause.message})`;
14 }
15
16 return error.message;
17 }
18
19 if (typeof error === "string") {
20 return error;
21 }
22
23 if (error === null || error === undefined) {
24 return "Unknown error";
25 }
26
27 try {
28 return JSON.stringify(error);
29 } catch {
30 return "Unknown error";
31 }
32};
33
34export const createSuccessResponse = <T>(data: T): IApiSuccessResponse<T> => ({
35 success: true,

Callers 15

safeMessageForFunction · 0.90
deliverToSubscriptionFunction · 0.90
getMethod · 0.90
purgeExpiredMethod · 0.90
sendMethod · 0.90
fanOutToChannelsFunction · 0.90
markDeliveryFailedFunction · 0.90
dispatchMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected