Welcome!

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

SignUp Now!

Declined Ability to ignore specified error messages?

May
12,846
164
This is not well thought out. For example ... I recently used a "DO ... /S ... " command which generated a lot of "access denied" errors. It would be nice to (in general) suppress specified error messages (while still getting unspecified ones). Maybe ...
Code:
set noerror=5
do ...
unset noerror
 
Here's what I'd like to avoid
Code:
on error ( if _syserr == 2 rem )
type no_exist
echo foo
cdd "e:\System Volume Information"
This suppresses the "file not found" message, as desired. But it also suppresses the "access denied" message from the last line.
 
Simply stop catching errors when the section ends

Code:
on error ( if _syserr == 2 rem )
type no_exist
on error
echo foo
cdd "e:\System Volume Information"

Now, the second error will be caught.

You can also put more elaborate tests in a sub and call it with
Code:
ON ERROR GOSUB CatchError %? %_? %_syserr ...
ending the section in the same way.

Regards, DJ
 
Yes, but if the same command might produce "file not found" or "access denied" I can't ignore "file not found" and still get the "access denied" message.

_SYSERR is otherwise a little flaky. In fact, I think ON ERROR prevents _SYSERR from being set at all. Here's OE.BTM.
Code:
v:\> type oe.btm
on error ( if %_syserr == 2 rem )
type no_exist
echo %_syserr
cdd "e:\System Volume Information"
echo %_syserr
And here it the result of running it in a newny-started instance.
Code:
v:\> oe.btm
0
0

Now I'll comment the ON ERROR line and run it.
Code:
v:\> oe.btm
TCC: (Sys) V:\oe.btm [2]  The system cannot find the file specified.
 "V:\no_exist"
2
TCC: (Sys) V:\oe.btm [4]  Access is denied.
 "e:\System Volume Information"
5

Now I'll uncomment that line and run it.
Code:
v:\> oe.btm
5
5
 
_SYSERR is set when TCC displays an error message. Your ON ERROR means you're never displaying an error message.
Can it (or a similar internal variable) be set earlier so that it can be tested in an ON ERROR routine?
 
Back
Top