File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ func (msg *Error) IsType(flags ErrorType) bool {
9191}
9292
9393// Unwrap returns the wrapped error, to allow interoperability with errors.Is(), errors.As() and errors.Unwrap()
94- func (msg * Error ) Unwrap () error {
94+ func (msg Error ) Unwrap () error {
9595 return msg .Err
9696}
9797
Original file line number Diff line number Diff line change @@ -126,4 +126,15 @@ func TestErrorUnwrap(t *testing.T) {
126126 require .ErrorIs (t , err , innerErr )
127127 var testErr TestErr
128128 require .ErrorAs (t , err , & testErr )
129+
130+ // Test non-pointer usage of gin.Error
131+ errNonPointer := Error {
132+ Err : innerErr ,
133+ Type : ErrorTypeAny ,
134+ }
135+ wrappedErr := fmt .Errorf ("wrapped: %w" , errNonPointer )
136+ // Check that 'errors.Is()' and 'errors.As()' behave as expected for non-pointer usage
137+ require .ErrorIs (t , wrappedErr , innerErr )
138+ var testErrNonPointer TestErr
139+ require .ErrorAs (t , wrappedErr , & testErrNonPointer )
129140}
You can’t perform that action at this time.
0 commit comments