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

May 24, 2010
855
0
Northlake, Il
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
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,463
88
Albuquerque, NM
prospero.unm.edu
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?
 
May 24, 2010
855
0
Northlake, Il
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
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,463
88
Albuquerque, NM
prospero.unm.edu
...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...
 
May 24, 2010
855
0
Northlake, Il
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
Thread starter Title Forum Replies Date
dcantor Request for documentation for ISO8601 plugin Plugins 4
H Latest ISO8601 plugin? Plugins 1
S WAD ISO8601 Plugin Plugins 15
S ISO8601 Plugin Plugins 4
dcantor @DATEDIFF UDF function using ISO8601 plugin functions Plugins 0
dcantor Request for ISO8601 plugin Plugins 19
Joe Caverly ISO8601 and TCC-RT Plugins 4
Joe Caverly November 10 is Thursday? (ISO8601-x64.dll) Plugins 6
Joe Caverly ISO8601-x64.dll and TCC 21 Plugins 5
Joe Caverly @ORD in ISO8601 Plugins 1
jbanaszczyk QCAL / iso8601 holidays.ini - POLAND Plugins 16
S ISO8601 desideratum Plugins 5
Joe Caverly 64-bit Plugin development using PureBasic Plugins 15
R New Plugin Plugins 0
Alpengreis elevated plugin questions Plugins 3
fpefpe utf-8 support in sdk/plugin api Plugins 4
S How to? Can @DU function in 4Utils64 plugin somehow cater for dirs with spaces? Plugins 3
vefatica Plugin access to arrays? Plugins 4
vefatica How big is a plugin's parameter buffer? Plugins 5
C @knownpath plugin Plugins 0
Charles Dye Updated OSD plugin Plugins 0
Joe Caverly C# plugin framework for JPSoft's TCC Plugins 0
dcantor Help for newest version of TEXTUTILS plugin Plugins 10
dcantor UISTUFF plugin missing help topic Plugins 12
M How to? Use SafeChars plugin... Plugins 2
dcantor Error in SAFECHARS plugin v 1.9.0 Plugins 2
vefatica Possible with a plugin? Plugins 6
dcantor Inconsistency between textutils plugin and wrap utility Plugins 2
M (Stupid?) Problem with 64-bit 4Utils plugin... Plugins 3
Charles Dye New plugin: QKeys Plugins 34
S Plugin to quickly locate all files hard linked together Plugins 5
S Documentation Plugin everything.dll Plugins 5
newbie How to? Multi-plugin installation errors, Re: FedUtils8 Plugins 7
vefatica Plugin -> thread -> Command() -> Ctrl-C? Plugins 20
Charles Dye A weirdoid plugin question Plugins 6
M SafeChars plugin misbehaving... Plugins 3
M A weird error re a plugin... Plugins 0
vefatica Plugin dilemma Plugins 2
fpefpe Documentation Plugin API/SDK Plugins 3
C Looking for Vince's old 4UTILS plugin for TCMD v8 Plugins 1
S DESKTOP plugin - anyone ? Plugins 0
C How to? a plugin to sort Outlook Express "rules" Plugins 0
M ISO Plugin: Yes, it's wonderful, but it could be yet more wonderful... Plugins 7
M The ISO plugin is wonderful, but it lacks a little something... Plugins 22
Charles Dye Beta plugin: HidePasswords Plugins 3
Frank 4console plugin Plugins 4
Joe Caverly Plugin and 64-bit TCC Plugins 3
C Problem with FixNames plugin Plugins 9
dcantor Suggestion and request for DBF plugin Plugins 6
dcantor Suggestion for SafeChars plugin Plugins 7

Similar threads