MCPcopy Create free account
hub / github.com/dailydotdev/apps / getLogErrorDetails

Function getLogErrorDetails

packages/shared/src/lib/errors.ts:86–118  ·  view source on GitHub ↗
(
  error: unknown,
)

Source from the content-addressed store, hash-verified

84 * stringifying one directly logs `{}`, and `undefined` drops the field.
85 */
86export const getLogErrorDetails = (
87 error: unknown,
88): LogErrorDetails | undefined => {
89 if (error === null || typeof error === 'undefined') {
90 return undefined;
91 }
92
93 const primitive = toLogString(error);
94 if (primitive) {
95 return { message: primitive };
96 }
97
98 if (typeof error !== 'object') {
99 return undefined;
100 }
101
102 const record = error as Record<string, unknown>;
103 const details: LogErrorDetails = {
104 message:
105 toLogString(record.message) ??
106 toLogString(record.detail) ??
107 toLogString(record.reason) ??
108 toLogString(record.description),
109 name: toLogString(record.name) ?? toLogString(record.type),
110 code: toLogString(record.code) ?? toLogString(record.status),
111 };
112
113 if (!details.message && !details.name && !details.code) {
114 return undefined;
115 }
116
117 return details;
118};

Callers 5

errors.spec.tsFile · 0.90
getBoostErrorExtraFunction · 0.90
getExcoErrorMessageFunction · 0.90
ExcoPlayerFunction · 0.90
useStoreKitPaymentFunction · 0.90

Calls 1

toLogStringFunction · 0.85

Tested by

no test coverage detected