The Chain of Responsibility for Error Handling
Passing exceptions through a gauntlet of "On Error" handlers.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Chain of Responsibility
ARCANUM SCHOOL: Abjuration // Mitigation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// VB PATTERN //
' IErrorHandler.cls
Public Sub HandleError(errNum As Long, ByRef handled As Boolean)
End Sub
' NextHandler.cls
Public NextLink As IErrorHandler
Implements IErrorHandler
Private Sub IErrorHandler_HandleError(errNum As Long, ByRef handled As Boolean)
If errNum = 429 Then ' ActiveX component can't create object
MsgBox "Suppressed ActiveX failure."
handled = True
ElseIf Not NextLink Is Nothing Then
NextLink.HandleError errNum, handled
End If
End Sub
When an error ripples up the stack in VB6, the Chain of Responsibility provides a structured alternative to global On Error Resume Next by passing the cursed Err.Number through a linked list of guardians.
Runic Tags:
#chain-of-responsibility
#error-handling
#com