global-functions: introduce $ExitError...

... as a simple macro to print error message on unintentional error.
This commit is contained in:
Christian Hesse 2024-12-06 10:06:56 +01:00
parent 48bcf8ee6e
commit 0d69f8952c

View file

@ -32,6 +32,7 @@
:global DownloadPackage; :global DownloadPackage;
:global EitherOr; :global EitherOr;
:global EscapeForRegEx; :global EscapeForRegEx;
:global ExitError;
:global FetchHuge; :global FetchHuge;
:global FetchUserAgentStr; :global FetchUserAgentStr;
:global FormatLine; :global FormatLine;
@ -425,6 +426,18 @@
:return $Return; :return $Return;
} }
# simple macro to print error message on unintentional error
:set ExitError do={
:local ExitOK [ :tostr $1 ];
:local ScriptName [ :tostr $2 ];
:global LogPrint;
:if ($ExitOK = "false") do={
$LogPrint error $ScriptName ("Script exited with error.");
}
}
# fetch huge data to file, read in chunks # fetch huge data to file, read in chunks
:set FetchHuge do={ :set FetchHuge do={
:local ScriptName [ :tostr $1 ]; :local ScriptName [ :tostr $1 ];