(details: BlockExecutionErrorDetails)
| 42 | } |
| 43 | |
| 44 | export function buildBlockExecutionError(details: BlockExecutionErrorDetails): Error { |
| 45 | const errorMessage = |
| 46 | details.error instanceof Error ? details.error.message : String(details.error) |
| 47 | const blockName = details.block.metadata?.name || details.block.id |
| 48 | const blockType = details.block.metadata?.id || 'unknown' |
| 49 | |
| 50 | const error = new Error(`${blockName}: ${errorMessage}`) |
| 51 | |
| 52 | const innerStatusCode = readStatusCode(details.error) |
| 53 | |
| 54 | Object.assign(error, { |
| 55 | blockId: details.block.id, |
| 56 | blockName, |
| 57 | blockType, |
| 58 | workflowId: details.context?.workflowId, |
| 59 | timestamp: new Date().toISOString(), |
| 60 | ...details.additionalInfo, |
| 61 | ...(innerStatusCode !== undefined ? { statusCode: innerStatusCode } : {}), |
| 62 | }) |
| 63 | |
| 64 | return error |
| 65 | } |
| 66 | |
| 67 | export function buildHTTPError(config: { |
| 68 | status: number |
no test coverage detected