aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-12-06 10:06:56 +0100
committerGravatar Christian Hesse <mail@eworm.de>2024-12-09 11:49:50 +0100
commit0d69f8952c25f3bfecd9e33c1520e74eebe42314 (patch)
tree73e4a6717918b7b226fdf7c2726ae31733ba0548
parent48bcf8ee6e92445b01f792f1c52af012ba05b7b4 (diff)
global-functions: introduce $ExitError...
... as a simple macro to print error message on unintentional error.
-rw-r--r--global-functions.rsc13
1 files changed, 13 insertions, 0 deletions
diff --git a/global-functions.rsc b/global-functions.rsc
index 6fec6dd..26ccc2a 100644
--- a/global-functions.rsc
+++ b/global-functions.rsc
@@ -32,6 +32,7 @@
:global DownloadPackage;
:global EitherOr;
:global EscapeForRegEx;
+:global ExitError;
:global FetchHuge;
:global FetchUserAgentStr;
:global FormatLine;
@@ -425,6 +426,18 @@
: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
:set FetchHuge do={
:local ScriptName [ :tostr $1 ];