Minor Simplification of Error Handling (+ $lerror) - 30/10/22 01:23 PM
This may well be seen as a very minor and somewhat insignificant feature request, but I figured I'd suggest it anyway...
Would it be possible to alter the behavior of the
(In other words, to be able to do something like:...without the script engine executing the error handling bits when no error actually occurs?)
The reason I ask is because it seems a bit redundant to have to explicitly check if
I realize that there is a risk that this change could potentially break scripts, and so I'd understand if it couldn't be implemented because of that... at the same time, however, I would also wonder how or why someone would be (mis)using
(On a related side-note, since this change would require that a copy of the value of
Would it be possible to alter the behavior of the
:error
label such that:- it can be considered valid to use
{ }
/ braces with it to open a new scope, and - the script engine would simply ignore the command (or (potentially unconditional)
{ }
-enclosed block of commands) that immediately follow(s) it?
(In other words, to be able to do something like:
Code
alias testerror { !echo -ga $1- :error { ; maybe a bit... "hacky", but allows the value of $error ; to be seen by the user before /reseterror clears it... !reseterror $input( $error , doh , Error: ) !return } }
The reason I ask is because it seems a bit redundant to have to explicitly check if
$error
contains a value every time the :error
label is used, since that label is, itself, intended to mark the branch the engine should take if a scripting error does occur. Of course, the value of $error
could still be checked if need be (say, to perform different error handling routines depending on the type of error), but for basic error handling, I feel like it shouldn't be necessary to do so.I realize that there is a risk that this change could potentially break scripts, and so I'd understand if it couldn't be implemented because of that... at the same time, however, I would also wonder how or why someone would be (mis)using
:error
in a way that implementing this would cause an issue in the first place.(On a related side-note, since this change would require that a copy of the value of
$error
be manually created before /reseterror
is called if one wishes to make use of its previously stored message, perhaps an identifier like $lerror
could be added to handle this automatically as well..?)