Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Test()
- On Error Resume Next
- Dim O1 As New Class1
- O1.DoSomething
- On Error GoTo 0
- End Sub
- Sub DoSomething()
- FindStuff
- 'create similar objects who perform similar operations and raise similar errors
- Dim O2 As New Class2
- O2.DoSomething
- End Sub
- Function FindStuff() As Stuff
- 'scan the WorkBook, the file system, etc. and organize the members of the object
- If CorruptedFileSystem Then Err.Raise 514, "File system corrupted"
- If CorruptedWorkBook Then Err.Raise 515, "WorkBook corrupted"
- If Found Then Set FindStuff = FoundStuff
- End Function
- Sub Test1()
- Dim O As New Class1
- O.UnhandledCall
- End Sub
- Sub Test2()
- On Error Resume Next
- Debug.Print 1 / 0
- Dim O As New Class1
- O.HandledCall
- On Error GoTo 0
- End Sub
- Sub UnhandledCall()
- Debug.Print 2 / 0
- End Sub
- Sub HandledCall()
- Debug.Print 3 / 0
- End Sub
- Sub Test()
- Dim foo As Class1
- Set foo = New Class1
- 'On Error Resume Next
- foo.DoSomething
- 'On Error GoTo 0
- End Sub
- Sub DoSomething()
- Err.Raise 5
- End Sub
- If CorruptedFileSystem Then Err.Raise 514, "File system corrupted"
- If CorruptedWorkBook Then Err.Raise 515, "WorkBook corrupted"
- If CorruptedFileSystem Then Err.Raise 514, "Class1.DoSomething", "File system corrupted"
- If CorruptedWorkBook Then Err.Raise 515, "Class1.DoSomething", "Workbook corrupted"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement