@@ -30,12 +30,12 @@ func ErrProtectedHandler(pushNotificationName string) error {
30
30
31
31
// ErrVoidProcessorRegister creates an error for when attempting to register a handler on void processor
32
32
func ErrVoidProcessorRegister (pushNotificationName string ) error {
33
- return NewProcessorError ("void_processor" , "register" , "push notifications are disabled" , nil )
33
+ return NewProcessorError ("void_processor" , "register" , pushNotificationName , "push notifications are disabled" , nil )
34
34
}
35
35
36
36
// ErrVoidProcessorUnregister creates an error for when attempting to unregister a handler on void processor
37
37
func ErrVoidProcessorUnregister (pushNotificationName string ) error {
38
- return NewProcessorError ("void_processor" , "unregister" , "push notifications are disabled" , nil )
38
+ return NewProcessorError ("void_processor" , "unregister" , pushNotificationName , "push notifications are disabled" , nil )
39
39
}
40
40
41
41
// Error message constants for consistency
@@ -81,30 +81,32 @@ func NewHandlerError(operation, pushNotificationName, reason string, err error)
81
81
82
82
// ProcessorError represents errors related to processor operations
83
83
type ProcessorError struct {
84
- ProcessorType string // "processor", "void_processor"
85
- Operation string // "process", "register", "unregister"
86
- Reason string
87
- Err error
84
+ ProcessorType string // "processor", "void_processor"
85
+ Operation string // "process", "register", "unregister"
86
+ PushNotificationName string // Name of the push notification involved
87
+ Reason string
88
+ Err error
88
89
}
89
90
90
91
func (e * ProcessorError ) Error () string {
91
92
if e .Err != nil {
92
- return fmt .Sprintf ("%s %s failed: %s (%v)" , e .ProcessorType , e .Operation , e .Reason , e .Err )
93
+ return fmt .Sprintf ("%s %s failed for '%s' : %s (%v)" , e .ProcessorType , e .Operation , e . PushNotificationName , e .Reason , e .Err )
93
94
}
94
- return fmt .Sprintf ("%s %s failed: %s" , e .ProcessorType , e .Operation , e .Reason )
95
+ return fmt .Sprintf ("%s %s failed for '%s' : %s" , e .ProcessorType , e .Operation , e . PushNotificationName , e .Reason )
95
96
}
96
97
97
98
func (e * ProcessorError ) Unwrap () error {
98
99
return e .Err
99
100
}
100
101
101
102
// NewProcessorError creates a new ProcessorError
102
- func NewProcessorError (processorType , operation , reason string , err error ) * ProcessorError {
103
+ func NewProcessorError (processorType , operation , pushNotificationName , reason string , err error ) * ProcessorError {
103
104
return & ProcessorError {
104
- ProcessorType : processorType ,
105
- Operation : operation ,
106
- Reason : reason ,
107
- Err : err ,
105
+ ProcessorType : processorType ,
106
+ Operation : operation ,
107
+ PushNotificationName : pushNotificationName ,
108
+ Reason : reason ,
109
+ Err : err ,
108
110
}
109
111
}
110
112
@@ -142,12 +144,14 @@ func IsVoidProcessorError(err error) bool {
142
144
// extractNotificationName attempts to extract the notification name from error messages
143
145
func extractNotificationName (err error ) string {
144
146
if handlerErr , ok := err .(* HandlerError ); ok {
145
- return handlerErr .PushNotificationName
147
+ if handlerErr .PushNotificationName != "" {
148
+ return handlerErr .PushNotificationName
149
+ }
146
150
}
147
151
if procErr , ok := err .(* ProcessorError ); ok {
148
- // For ProcessorError, we don't have direct access to the notification name
149
- // but in a real implementation you could store this in the struct
150
- return "unknown"
152
+ if procErr . PushNotificationName != "" {
153
+ return procErr . PushNotificationName
154
+ }
151
155
}
152
156
return "unknown"
153
157
}
0 commit comments