ON ERROR and pipes?

May 20, 2008
11,377
98
Syracuse, NY, USA
That other thread was becoming a bit tedious. It seems that DO has nothing to do with it. It's just ON ERROR and a pipe. It's as though when ON ERROR is set and an error occurs, pipes are killed.

Code:
v:\> type batch3.btm
if "%1" = "use_on_error" on error echo ERROR!!!!!
echo 2
dir c:\foobar
echo 1


ON ERROR not set; pipe not killed:

Code:
v:\> batch3.btm | sort
TCC: (Sys) V:\batch3.btm [3]  The system cannot find the file specified.
"C:\foobar"

                   0 bytes in 0 files and 0 dirs
     718,061,199,360 bytes free
Volume in drive C is Windows      Serial number is 3ed6:5d0d
1
2


ON ERROR set; pipe killed:

Code:
v:\> batch3.btm use_on_error | sort

v:\>
 

rconn

Administrator
Staff member
May 14, 2008
12,340
149
WAD.

An ON ERROR condition will check for a child pipe process, and if one is running TCC will do a TerminateProcess API call on that process.

Think about the scenario:

1) You want to send output from the batch file to another process.
2) You're worried enough about the result that you put an ON ERROR in the batch file.
3) You got an error, and you have no way of informing the child pipe process about it.
4) So you want to pretend nothing bad happened, and the child should process bad data?
 
May 20, 2008
11,377
98
Syracuse, NY, USA
WAD.

An ON ERROR condition will check for a child pipe process, and if one is running TCC will do a TerminateProcess API call on that process.

Think about the scenario:

1) You want to send output from the batch file to another process.
2) You're worried enough about the result that you put an ON ERROR in the batch file.
3) You got an error, and you have no way of informing the child pipe process about it.
4) So you want to pretend nothing bad happened, and the child should process bad data?

No to number 4. That's what the ON ERROR is all about ... don't produce output if it's goind to be bad. As for number 3, the child pipe doesn't need to know about it if it's not sent bad outout. That makes more sense to me. What's the alternative ... cancel the whole thing? If I want to continue, I must invent my own test for an error. ON ERROR is easier.

And I could accomplish your goal with ON ERROR LEAVE (if I were piping DO) or ON ERROR QUIT, or ON ERROR GOTO ...

If anything, the default error handler qhould kill the pipe (I am not requesting that). When I say ON ERROR, I want to be in control.
 
May 20, 2008
11,377
98
Syracuse, NY, USA
And ON ERROR is not only easier, it suppresses error messages. Without it *I* have to worry about suppressing error messages.
 

rconn

Administrator
Staff member
May 14, 2008
12,340
149
You're assuming (incorrectly in many / most cases) that nothing is going to happen on an error other than an error message being displayed (or intercepted and not displayed). For a DIR, that's true. For COPY / DEL / MOVE / REN -- not so much.

There is 0% chance I'm going to change the current default behavior. If you want to suggest an optional alternate behavior (and its syntax), you should post it on the Suggestions Forum.
 
May 20, 2008
11,377
98
Syracuse, NY, USA
There is 0% chance I'm going to change the current default behavior. If you want to suggest an optional alternate behavior (and its syntax), you should post it on the Suggestions Forum.
They are two very different behaviors. IMHO an (advanced) INI directive, KillPipesOnError=YES|No, would be appropriate. It wouldn't need a spot in the OPTION dialog but it should have a help page which makes it clear that it only applies when ON ERROR is in effect.
 
May 20, 2008
11,377
98
Syracuse, NY, USA
They are two very different behaviors. IMHO an (advanced) INI directive, KillPipesOnError=YES|No, would be appropriate. It wouldn't need a spot in the OPTION dialog but it should have a help page which makes it clear that it only applies when ON ERROR is in effect.
Better yet (for emphasis) ONERRORkillPipes=YES|No or ONERRORKeepPipes=NO|Yes.
 
Similar threads
Thread starter Title Forum Replies Date
C Copy (sys) error Support 3
T Error: This page can’t be displayed Make sure the web address //ieframe.dll/dnserrordiagoff.htm# is correct. Support 8
kb6ojs How to? "Specified Account Already Exists" error installing TCMD v27 Support 12
samintz How to? Abort on error DO loop Support 10
mfarah Fixed The DATE command produces the wrong error message. Support 1
vefatica ON ERROR terminates DO loop. Support 0
C Google intregration error Support 4
C FB intregration error Support 0
gworley rd (Remove Directory) gives interesting error: Support 2
D How to? Skip removing directory (RMDIR) without error message Support 2
Dmitry L. Kobyakov Documentation Error in the Help: the WINDOW command Support 0
M Strange error messages from TCC in FTP copy Support 7
vefatica Error message from TOUCH Support 2
R FIND command error Support 9
fpefpe Python dll error Support 3
D error in help documentation? Support 0
R FOR usage error from TCC but not from CMD Support 16
K_Meinhard Help file error Support 1
X small translation error. Support 0
W pdir returns diff results between tcc and tcmd - one is an error msg Support 5
Dmitry L. Kobyakov From old version: had the setup's error been corrected? Support 6
vefatica Why no error message? Support 2
MickeyF Why does this batch file give me 'unknown command "else"' error? Support 17
Joe Caverly TASKDIALOG Help link error Support 1
J Error "Contents lost before copy" Support 3
vefatica What's causing this error? Support 4
vefatica Error 203? Support 4
C Activation Error. Support 2
J Error running Python at command line Support 9
Joe Caverly PSHELL Error? Support 16
M Fixed PSHELL command returns error Support 2
vefatica REGDIR, strange error message Support 7
O Error in plugin /u Support 2
O TPIPE: Error -Can´t access textpipeengine.dll Support 24
fpefpe How to? script error Support 1
fpefpe How to? script error Support 0
D Error 0xc0000142 and FAR Manager Support 10
F Powershell call fails with "Scripting Integrator 2016 (PowerShell)" license error Support 9
cgunhouse FTP Error Support 5
C How to? Error updating from 20.00.16 to 20.00.21 Support 10
vefatica Missing post and security error Support 4
samintz Documentation TCANSI error Support 8
vefatica WAD ON ERROR GOTO ... Support 11
dcantor Documentation Documentation error in UNSET Support 0
vefatica Error updating Support 2
C tpipe /simple=28 error Support 5
B Fixed Error messages from TCMD.INI Support 2
Alpengreis [Bug?] View (V) Prefs Error (TC 18.00.27 x64) Support 4
Bill de Haan HTTP Protocol error. 407 Proxy Authentication Required. Support 3
vefatica DO /S ... suppress error? Support 1

Similar threads