What does the Accept Error Message operator do?

I came up with some VBScript examples and I saw the On Error Resume Next statement mainly at the beginning of the script.

What is he doing?

+48
error-handling vbscript
Feb 04 '10 at 20:18
source share
7 answers

It basically tells the program when you encounter an error, just continue on the next line.

+64
04 Feb '10 at 20:19
source share

It's worth noting that even when On Error Resume Next is in effect, the Err object is still populated when an error occurs, so you can still handle C-style errors.

 On Error Resume Next DangerousOperationThatCouldCauseErrors If Err Then WScript.StdErr.WriteLine "error " & Err.Number WScript.Quit 1 End If On Error GoTo 0 
+32
Feb 05 '10 at 15:49
source share

If an error occurs, execution will continue on the next line without interrupting the script.

+21
Feb 04 '10 at 20:19
source share

This means that when an error occurs in a line, it tells vbscript to continue execution without interrupting the script. Sometimes On Error follows the Goto label to change the execution flow, something like this in the Sub code block, now you know why and how using Goto can lead to spaghetti code:

 Sub MySubRoutine ()
    On Error Goto ErrorHandler

    REM VB code ...

    REM More VB Code ...

 Exit_MySubRoutine:

    REM Disable the Error Handler!

    On Error Goto 0

    REM Leave ....
    Exit sub

 ErrorHandler:

    REM Do something about the Error

    Goto Exit_MySubRoutine
 End sub
+9
Feb 04 '10 at 20:28
source share

In the error message - indicates that when a run-time error occurs, control passes to the next statement. Once the Err object is populated (Err.Number, Err.Count, etc.)

+3
Jun 29 '15 at 18:19
source share

In the field "Error during reconnection" means that "If an error occurs" it will resume until the next line.

eg. if you try the Try block, this will stop the script if an error occurs

0
Aug 16 '16 at 20:10
source share

It allows you to handle errors. Below is partly https://msdn.microsoft.com/en-us/library/5hsw66as.aspx

 ' Enable error handling. When a run-time error occurs, control goes to the statement immediately following the statement where the error occurred, and execution continues from that point. On Error Resume Next SomeCodeHere If Err.Number = 0 Then WScript.Echo "No Error in SomeCodeHere." Else WScript.Echo "Error in SomeCodeHere: " & Err.Number & ", " & Err.Source & ", " & Err.Description ' Clear the error or you'll see it again when you test Err.Number Err.Clear End If SomeMoreCodeHere If Err.Number <> 0 Then WScript.Echo "Error in SomeMoreCodeHere:" & Err.Number & ", " & Err.Source & ", " & Err.Description ' Clear the error or you'll see it again when you test Err.Number Err.Clear End If ' Disables enabled error handler in the current procedure and resets it to Nothing. On Error Goto 0 ' There are also `On Error Goto -1`, which disables the enabled exception in the current procedure and resets it to Nothing, ' and `On Error Goto line`, which enables the error-handling routine that starts at the line specified in the required line argument. The line argument is any line label or line number. If a run-time error occurs, control branches to the specified line, making the error handler active. The specified line must be in the same procedure as the On Error statement, or a compile-time error will occur. 
0
Apr 25 '17 at 18:52
source share



All Articles