* Creates appropriate error based on build output * @param {Object} params - Parameters for error handling * @param {Array } params.buildOutput - Complete build output lines * @param {Error|Object} [params.error] - Original error if available * @returns {ServerlessError} Formatted
({ containerName, buildOutput })
| 576 | * @returns {ServerlessError} Formatted error with appropriate message |
| 577 | */ |
| 578 | #handleBuildFailure({ containerName, buildOutput }) { |
| 579 | const fullBuildLog = buildOutput.join('\n') |
| 580 | |
| 581 | // Remove last linebreak if it exists |
| 582 | const lastLinebreakIndex = fullBuildLog.lastIndexOf('\n') |
| 583 | const truncatedBuildLog = |
| 584 | lastLinebreakIndex !== -1 |
| 585 | ? fullBuildLog.slice(0, lastLinebreakIndex) |
| 586 | : fullBuildLog |
| 587 | |
| 588 | this.logger.error( |
| 589 | `Docker build failed for "${containerName}". Here's Docker's full build output:\n\n${truncatedBuildLog}`, |
| 590 | ) |
| 591 | |
| 592 | // Check for common Docker failure patterns |
| 593 | if (fullBuildLog.includes('no space left on device')) { |
| 594 | return new ServerlessError( |
| 595 | `Docker build failed for "${containerName}": No disk space available`, |
| 596 | 'KONTINUUM_ECR_CREATE_REPOOSITORY_FAILED', |
| 597 | { stack: false }, |
| 598 | ) |
| 599 | } |
| 600 | if (fullBuildLog.includes('network timeout')) { |
| 601 | return new ServerlessError( |
| 602 | `Docker build failed for "${containerName}": Network timeout`, |
| 603 | 'KONTINUUM_ECR_CREATE_REPOOSITORY_FAILED', |
| 604 | { stack: false }, |
| 605 | ) |
| 606 | } |
| 607 | if (fullBuildLog.includes('permission denied')) { |
| 608 | return new ServerlessError( |
| 609 | `Docker build failed for "${containerName}": Permission denied`, |
| 610 | 'KONTINUUM_ECR_CREATE_REPOOSITORY_FAILED', |
| 611 | { stack: false }, |
| 612 | ) |
| 613 | } |
| 614 | // Default error |
| 615 | return new ServerlessError( |
| 616 | `Docker build failed for "${containerName}". Review Docker's build output above for details.`, |
| 617 | 'KONTINUUM_ECR_CREATE_REPOOSITORY_FAILED', |
| 618 | { stack: false }, |
| 619 | ) |
| 620 | } |
| 621 | |
| 622 | /** |
| 623 | * Tails logs for a container |
no test coverage detected