Merge pull request #2305 from balena-io/performResolution-error-handling

push, build: Improve error handling (identify which service failed)
This commit is contained in:
bulldozer-balena[bot] 2021-08-14 00:21:11 +00:00 committed by GitHub
commit 48d7d0ef5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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?`,
);
}
}