From 0d69f8952c25f3bfecd9e33c1520e74eebe42314 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 6 Dec 2024 10:06:56 +0100 Subject: global-functions: introduce $ExitError... ... as a simple macro to print error message on unintentional error. --- global-functions.rsc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'global-functions.rsc') 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 ]; -- cgit v1.2.3-70-g09d2