Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- On Error Resume Next '' ignore errors
- SomeIgnorableFunction()
- On Error GoTo 0 '' removes error ignoring
- SomeImportantFunction()
- On Error GoTo HandleError '' on error will code jump to specified signal
- Dim a
- a = 15 / 0
- GoTo Finish '' skips error handling
- HandleError:
- Dim msg
- Set msg = Err.Description & vbCrLf & Err.Number
- MsgBox msg
- Finish:
- '' there is end of sciprt
- Option Explicit
- On Error Resume Next ' Potential error coming up
- Dim MyArray(5)
- MyArray(7) = "BWA HA HA"
- If Err.Number <> 0 Then
- LogError(Err)
- Err.Clear
- End If
- On Error Goto 0 ' Stop looking for errors
- Sub LogError(Details)
- Dim fs : Set fs = CreateObject("Scripting.FileSystemObject")
- Dim logFile : Set logFile = fs.OpenTextFile("c:errors.log", 8, True)
- logFile.WriteLine(Now() & ": Error: " & Details.Number & " Details: " & Details.Description)
- End Sub
- private sub BucketList()
- do while 1=1
- ClimbMountain(top)
- if err.Number <> 0 then exit do
- SwimOcean(deep)
- if err.Number <> 0 then exit do
- GiveErrorHandlingToVBS(isNeverGoingToHappen)
- if err.Number <> 0 then exit do
- exit do
- loop
- 'Error Handler
- if err.Number <> 0 then
- 'handle error
- end if
- end sub
Add Comment
Please, Sign In to add comment