global-functions: make $ExitError a wrapper for $ExitOnError

This commit is contained in:
Christian Hesse 2026-01-20 10:35:12 +01:00
parent bbf2f5abbf
commit 843ec3030c

View file

@ -474,19 +474,16 @@
:return $Return; :return $Return;
} }
# simple macro to print error message on unintentional error # wrapper for $ExitOnError with additional parameter
:set ExitError do={ :set ExitError do={
:local ExitOK [ :tostr $1 ]; :local ExitOK [ :tostr $1 ];
:local Name [ :tostr $2 ]; :local Name [ :tostr $2 ];
:local Error [ :tostr $3 ]; :local Error [ :tostr $3 ];
:global IfThenElse; :global ExitOnError;
:global LogPrint;
:if ($ExitOK = "false") do={ :if ($ExitOK = "false") do={
$LogPrint error $Name ([ $IfThenElse ([ :pick $Name 0 1 ] = "\$") \ $ExitOnError $Name $Error;
"Function" "Script" ] . " '" . $Name . "' exited with error" . \
[ $IfThenElse (!($Error ~ "^(|true|false)\$")) (": " . $Error) "." ]);
} }
} }