MCPcopy
hub / github.com/chartbrew/chartbrew / normalizeError

Function normalizeError

server/modules/updateAudit.js:217–252  ·  view source on GitHub ↗
(error, fallbackStage = "unknown")

Source from the content-addressed store, hash-verified

215}
216
217function normalizeError(error, fallbackStage = "unknown") {
218 if (!error) {
219 return {
220 errorStage: fallbackStage,
221 errorClass: "Error",
222 errorCode: null,
223 errorMessage: "Unknown error",
224 };
225 }
226
227 if (isOutboundPolicyError(error)) {
228 const serializedPolicyError = serializeOutboundPolicyError(error);
229 return {
230 errorStage: "policy",
231 errorClass: error.name || "OutboundPolicyError",
232 errorCode: error.code || serializedPolicyError?.code || null,
233 errorMessage: truncateString(
234 serializedPolicyError?.message || error.message || String(error),
235 ERROR_MESSAGE_LENGTH
236 ),
237 };
238 }
239
240 const stage = error.auditStage || fallbackStage;
241 const errorCode = error.code
242 || (error.original && error.original.code)
243 || error.statusCode
244 || null;
245
246 return {
247 errorStage: stage,
248 errorClass: error.name || typeof error,
249 errorCode: errorCode ? String(errorCode) : null,
250 errorMessage: truncateString(error.message || String(error), ERROR_MESSAGE_LENGTH),
251 };
252}
253
254function getDurationMs(startedAt, finishedAt) {
255 const normalizedStartedAt = hydrateDate(startedAt);

Callers 1

failRunFunction · 0.85

Calls 3

isOutboundPolicyErrorFunction · 0.85
truncateStringFunction · 0.85

Tested by

no test coverage detected