(traceContext, error, options = {})
| 546 | } |
| 547 | |
| 548 | async function failRun(traceContext, error, options = {}) { |
| 549 | if (!traceContext) { |
| 550 | return null; |
| 551 | } |
| 552 | |
| 553 | const normalizedError = normalizeError(error, options.stage || "unknown"); |
| 554 | const finishedAt = options.finishedAt || new Date(); |
| 555 | const summary = sanitizePayload(options.summary || null); |
| 556 | const payload = sanitizePayload({ |
| 557 | ...options.payload, |
| 558 | ...normalizedError, |
| 559 | }); |
| 560 | |
| 561 | const runFailedEvent = await startEvent(traceContext, "run_failed", payload); |
| 562 | await finishEvent(traceContext, runFailedEvent, "failed", payload); |
| 563 | |
| 564 | await updateRunContext(traceContext, { |
| 565 | status: options.status || "failed", |
| 566 | finishedAt, |
| 567 | durationMs: getDurationMs(traceContext.startedAt || finishedAt, finishedAt), |
| 568 | errorStage: normalizedError.errorStage, |
| 569 | errorClass: normalizedError.errorClass, |
| 570 | errorCode: normalizedError.errorCode, |
| 571 | errorMessage: normalizedError.errorMessage, |
| 572 | summary, |
| 573 | }); |
| 574 | |
| 575 | return traceContext; |
| 576 | } |
| 577 | |
| 578 | async function recordInstantEvent(traceContext, stage, payload = {}, status = "success") { |
| 579 | const event = await startEvent(traceContext, stage, payload); |
no test coverage detected