You can regroup your steps functions calls in a facade function :
sub facade()
call step1()
call step2()
call step3()
call step4()
call step5()
end sub
Then, let your error handling be in an upper function that calls the facade :
sub main()
On error resume next
call facade()
If Err.Number <> 0 Then
' MsgBox or whatever. You may want to display or log your error there
msgbox Err.Description
Err.Clear
End If
On Error Goto 0
end sub
Now, let's suppose step3()
raises an error. Since facade()
doesn't handle errors (there is no On error resume next
in facade()
), the error will be returned to main()
and step4()
and step5()
won't be executed.
Your error handling is now refactored in 1 code block