MCPcopy
hub / github.com/single-spa/single-spa / transformErr

Function transformErr

src/applications/app-errors.js:58–101  ·  view source on GitHub ↗
(ogErr, appOrParcel, newStatus)

Source from the content-addressed store, hash-verified

56}
57
58export function transformErr(ogErr, appOrParcel, newStatus) {
59 const errPrefix = `${objectType(appOrParcel)} '${toName(
60 appOrParcel
61 )}' died in status ${appOrParcel.status}: `;
62
63 let result;
64
65 if (ogErr instanceof Error) {
66 try {
67 ogErr.message = errPrefix + ogErr.message;
68 } catch (err) {
69 /* Some errors have read-only message properties, in which case there is nothing
70 * that we can do.
71 */
72 }
73 result = ogErr;
74 } else {
75 console.warn(
76 formatErrorMessage(
77 30,
78 __DEV__ &&
79 `While ${appOrParcel.status}, '${toName(
80 appOrParcel
81 )}' rejected its lifecycle function promise with a non-Error. This will cause stack traces to not be accurate.`,
82 appOrParcel.status,
83 toName(appOrParcel)
84 )
85 );
86 try {
87 result = Error(errPrefix + JSON.stringify(ogErr));
88 } catch (err) {
89 // If it's not an Error and you can't stringify it, then what else can you even do to it?
90 result = ogErr;
91 }
92 }
93
94 result.appOrParcelName = toName(appOrParcel);
95
96 // We set the status after transforming the error so that the error message
97 // references the state the application was in before the status change.
98 appOrParcel.status = newStatus;
99
100 return result;
101}

Callers 6

toBootstrapPromiseFunction · 0.90
setSkipBecauseBrokenFunction · 0.90
toUnmountPromiseFunction · 0.90
unmountAppOrParcelFunction · 0.90
toUpdatePromiseFunction · 0.90
handleAppErrorFunction · 0.85

Calls 3

objectTypeFunction · 0.90
toNameFunction · 0.90
formatErrorMessageFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…