-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherrors.go
More file actions
30 lines (24 loc) · 785 Bytes
/
errors.go
File metadata and controls
30 lines (24 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package sse
import (
"fmt"
)
// ErrValidation represents errors related to event validation or encoding
// that don't necessarily require terminating the event stream.
var ErrValidation error = &validationError{}
type validationError struct {
Message string
Cause error // Wrapped underlying error
}
// Error implements the error interface
func (e *validationError) Error() string {
if e.Cause != nil {
return fmt.Sprintf("sse: %s: %v", e.Message, e.Cause)
}
return fmt.Sprintf("sse: %s", e.Message)
}
// Unwrap returns the underlying cause if present
func (e *validationError) Unwrap() error {
return e.Cause
}
// Is implements error matching and returns true for any validationError
func (e *validationError) Is(target error) bool { return target == ErrValidation }