Ability to ignore specified error messages?

May 20, 2008
9,351
62
Syracuse, NY, USA
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
 
  • Like
Reactions: Charles G
May 20, 2008
9,351
62
Syracuse, NY, USA
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.
 
Apr 13, 2010
243
5
58
The Hague
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
 
May 20, 2008
9,351
62
Syracuse, NY, USA
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