From c7bbbc4159185d804c0d05c8768252a5ce4b0341 Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Thu, 5 Aug 2021 14:44:23 +0100 Subject: [PATCH] push, build: Improve error handling (identify which service failed) Change-type: patch --- lib/utils/compose_ts.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/utils/compose_ts.ts b/lib/utils/compose_ts.ts index 1f5e137b..96801613 100644 --- a/lib/utils/compose_ts.ts +++ b/lib/utils/compose_ts.ts @@ -1063,18 +1063,21 @@ async function performResolution( if (!buildTask.buildStream) { continue; } - // Consume each task.buildStream in order to trigger the - // resolution events that define fields like: - // task.dockerfile, task.dockerfilePath, - // task.projectType, task.resolved - // This mimics what is currently done in `resin-builder`. - const clonedStream: Pack = await cloneTarStream( - buildTask.buildStream, - ); - buildTask.buildStream = clonedStream; - if (!buildTask.external && !buildTask.resolved) { + let error: Error | undefined; + try { + // Consume each task.buildStream in order to trigger the + // resolution events that define fields like: + // task.dockerfile, task.dockerfilePath, + // task.projectType, task.resolved + // This mimics what is currently done in `resin-builder`. + buildTask.buildStream = await cloneTarStream(buildTask.buildStream); + } catch (e) { + error = e; + } + if (error || (!buildTask.external && !buildTask.resolved)) { + const cause = error ? `${error}\n` : ''; throw new ExpectedError( - `Project type for service "${buildTask.serviceName}" could not be determined. Missing a Dockerfile?`, + `${cause}Project type for service "${buildTask.serviceName}" could not be determined. Missing a Dockerfile?`, ); } }