diff --git a/src/libstore/build/substitution-goal.cc b/src/libstore/build/substitution-goal.cc index 93867007d3a..d29e0f911eb 100644 --- a/src/libstore/build/substitution-goal.cc +++ b/src/libstore/build/substitution-goal.cc @@ -74,6 +74,9 @@ void PathSubstitutionGoal::tryNext() if (subs.size() == 0) { /* None left. Terminate this goal and let someone else deal with it. */ + if (subError.has_value()) { + throw std::move(*subError); + } /* Hack: don't indicate failure if there were no substituters. In that case the calling derivation should just do a @@ -111,19 +114,12 @@ void PathSubstitutionGoal::tryNext() } catch (InvalidPath &) { tryNext(); return; - } catch (SubstituterDisabled &) { - if (settings.tryFallback) { - tryNext(); - return; - } - throw; } catch (Error & e) { - if (settings.tryFallback) { - logError(e.info()); - tryNext(); - return; + if (!subError.has_value()) { + subError = std::move(e); } - throw; + tryNext(); + return; } if (info->path != storePath) { diff --git a/src/libstore/build/substitution-goal.hh b/src/libstore/build/substitution-goal.hh index 1d389d328ff..2b0b7ee584c 100644 --- a/src/libstore/build/substitution-goal.hh +++ b/src/libstore/build/substitution-goal.hh @@ -22,6 +22,11 @@ struct PathSubstitutionGoal : public Goal */ std::optional subPath; + /** + * The first error we came across while substituting. + */ + std::optional subError; + /** * The remaining substituters. */ diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc index 85c5eed4c01..854d236beb2 100644 --- a/src/libstore/http-binary-cache-store.cc +++ b/src/libstore/http-binary-cache-store.cc @@ -89,7 +89,7 @@ class HttpBinaryCacheStore : public virtual HttpBinaryCacheStoreConfig, public v void maybeDisable() { auto state(_state.lock()); - if (state->enabled && settings.tryFallback) { + if (state->enabled) { int t = 60; printError("disabling binary cache '%s' for %s seconds", getUri(), t); state->enabled = false; diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 28689e100e2..9ff986e1652 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -592,10 +592,7 @@ void Store::querySubstitutablePathInfos(const StorePathCAMap & paths, Substituta } catch (InvalidPath &) { } catch (SubstituterDisabled &) { } catch (Error & e) { - if (settings.tryFallback) - logError(e.info()); - else - throw; + logError(e.info()); } } }