Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

ISO8601 Plugin not "reporting" errors to TCC...

May
855
0
Charles,

I'm rather sure I'm not telling you anything you don't already know, but given my current "talent" for making errors I would really find it nice if your plugin "reported" errors to TCC (via a "On Error" or "On ErrMsg" command and is something not earthshaking for you to implement). Specifically, given a batch file that I wrote containing the following to specifically "illustrate" the issue in all of its "glory" (;)):
Code:
   @Echo Off
   On ErrorMsg Goto HaveAnError
   Set /A Age=2**64-1
   @Echo %@AgeDate[%Age]
   @Echo No error caught!
   Quit 16
:HaveAnError
   @Echo Yes it was an error!
   Quit 0
Here is the (expected by you, I'm rather sure) output:
Code:
ISO8601 plugin: Z:\DemoAgeDateFailureToDetectAnError.btm [5]  Age out of range "184
46744073709551615"
No error caught!
Is this something you can fix/will ever be fixed?

- Dan
 
I've taken a look at it, and this seems to be a consequence of the fact that I'm displaying my own error messages rather than returning a Windows error code and letting TCC display the error. The only way I see to fix it would be to return generic errors ("Invalid parameter", e.g.) instead of the more specific ones I'm showing now. I don't much like that idea.

Rex, would it be possible for TCC to call the ON ERROR handler when a plugin function returns a negative value?
 
Thank you, Charles. I've "cleverly" found what could probably be considered the most important "half" of the solution (being able to detect that an error occurred and therefore either handle it directly or report to the user what the "original" cause of this error was), but the whole solution (also being able to suppress this particular error message) would certainly be better. How do I "detect" that half? A very short and simple code sequence to illustrate:
Code:
  Set Result=?????
  Set Result=%@AgeDate[%Age] >&>NUL:
  If "%Result" == "?????" Goto Failed
  :: Here if succeeded...
Note that the ">&>" was a failed attempt to suppress the error message.

So the idea is that when the plugin fails the variable "Result" will still contain the value it had before the plugin function was invoked. Why is it only "half" the solution? Because the error message is still displayed. This could be somewhat annoying but is only annoying because at least the "right" answer is being returned (i.e., the correct answer when the "Age" is within the "acceptable range" that can be converted), or "?????" (in this example) if the "Age" is not within that "acceptable" range so that the error can be detected and then handled appropriately by the batch file.

Just as a note, my own personal convention is that "internal" errors are absolutely never shown to the user unless they are both important and can not be handled/corrected; and even in those situations errors are very often at the end of a possibly very long chain of "events" based on user (or other) input that was not directly related to the error but rather the error was end of result of that chain of events caused by what the error "really" was; and what the error "really" was (only "known" by the batch file in question) is what should be reported to the user so that the user then has the chance to correct that and not have to "deduce" what the "real" error was based upon a (possibly almost random) consequence of that error.

But thank you, again, Charles!

- Dan
 
...but the whole solution (also being able to suppress this particular error message) would certainly be better.

Code:
  Set Result=?????
  Set Result=%@AgeDate[%Age] >&>NUL:
  If "%Result" == "?????" Goto Failed
  :: Here if succeeded...

Note that the ">&>" was a failed attempt to suppress the error message.

Oh, yeah. I've bumped into that myself, and it always confuses me too. It's not the plugin; you'll see the same thing if you cause an error in an internal function:

Code:
set test=%@eval[] >& nul:

What's happening is that variable expansion (including functions) is done before redirection; otherwise you wouldn't be able to redirect to a file specified in a variable. You can work around it using parentheses:

Code:
  Set Result=?????
  ( Set Result=%@AgeDate[%Age] ) >&>NUL:
  If "%Result" == "?????" Goto Failed
  :: Here if succeeded...
 
Thank you, Charles, I wouldn't have guessed. I would imagine that that is because I've never run into a situation before where an "internal function" would have an error that I couldn't anticipate and therefore avoid. - Dan
 

Similar threads

Back
Top