dieHook: Add `die` utility function
Calling `die "Error message"` causes the current script to exit with an error, printing a backtrace
This commit is contained in:
parent
ba68231273
commit
12354b8eb5
|
@ -0,0 +1,21 @@
|
|||
# Exit with backtrace and error message
|
||||
#
|
||||
# Usage: die "Error message"
|
||||
die() {
|
||||
# Let us be a little sloppy with errors, because otherwise the final
|
||||
# invocation of `caller` below will cause the script to exit.
|
||||
set +e
|
||||
|
||||
# Print our error message
|
||||
printf "\nBuilder called die: %b\n" "$*"
|
||||
printf "Backtrace:\n"
|
||||
|
||||
# Print a backtrace.
|
||||
local frame=0
|
||||
while caller $frame; do
|
||||
((frame++));
|
||||
done
|
||||
printf "\n"
|
||||
|
||||
exit 1
|
||||
}
|
|
@ -100,6 +100,8 @@ with pkgs;
|
|||
|
||||
diffPlugins = (callPackage ../build-support/plugins.nix {}).diffPlugins;
|
||||
|
||||
dieHook = makeSetupHook {} ../build-support/setup-hooks/die.sh;
|
||||
|
||||
dockerTools = callPackage ../build-support/docker { };
|
||||
|
||||
docker_compose = pythonPackages.docker_compose;
|
||||
|
@ -287,7 +289,8 @@ with pkgs;
|
|||
inherit contents compressor prepend;
|
||||
};
|
||||
|
||||
makeWrapper = makeSetupHook { } ../build-support/setup-hooks/make-wrapper.sh;
|
||||
makeWrapper = makeSetupHook { deps = [ dieHook ]; }
|
||||
../build-support/setup-hooks/make-wrapper.sh;
|
||||
|
||||
makeModulesClosure = { kernel, rootModules, allowMissing ? false }:
|
||||
callPackage ../build-support/kernel/modules-closure.nix {
|
||||
|
|
Loading…
Reference in New Issue