mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-01-21 16:39:32 +00:00
global-functions: introduce $ExitOnError
This is just like $ExitError, but first parameter is dropped. We will not need it now that we can exit a script with :exit.
This commit is contained in:
parent
9347063647
commit
bbf2f5abbf
1 changed files with 14 additions and 0 deletions
|
|
@ -36,6 +36,7 @@
|
||||||
:global EitherOr;
|
:global EitherOr;
|
||||||
:global EscapeForRegEx;
|
:global EscapeForRegEx;
|
||||||
:global ExitError;
|
:global ExitError;
|
||||||
|
:global ExitOnError;
|
||||||
:global FetchHuge;
|
:global FetchHuge;
|
||||||
:global FetchUserAgentStr;
|
:global FetchUserAgentStr;
|
||||||
:global FileExists;
|
:global FileExists;
|
||||||
|
|
@ -489,6 +490,19 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# simple macro to print error message on unintentional error
|
||||||
|
:set ExitOnError do={
|
||||||
|
:local Name [ :tostr $1 ];
|
||||||
|
:local Error [ :tostr $2 ];
|
||||||
|
|
||||||
|
:global IfThenElse;
|
||||||
|
:global LogPrint;
|
||||||
|
|
||||||
|
$LogPrint error $Name ([ $IfThenElse ([ :pick $Name 0 1 ] = "\$") \
|
||||||
|
"Function" "Script" ] . " '" . $Name . "' exited with error" . \
|
||||||
|
[ $IfThenElse (!($Error ~ "^(|true|false)\$")) (": " . $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 ];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue