TestErrorUnwrap() — gin Function Reference
Architecture documentation for the TestErrorUnwrap() function in errors_test.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD 86e6679c_2bf7_8fc6_7bcb_b420e129eadf["TestErrorUnwrap()"] bd4678df_f6bd_26e2_4f83_00536939b6d9["errors_test.go"] 86e6679c_2bf7_8fc6_7bcb_b420e129eadf -->|defined in| bd4678df_f6bd_26e2_4f83_00536939b6d9 style 86e6679c_2bf7_8fc6_7bcb_b420e129eadf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
errors_test.go lines 116–140
func TestErrorUnwrap(t *testing.T) {
innerErr := TestErr("some error")
// 2 layers of wrapping : use 'fmt.Errorf("%w")' to wrap a gin.Error{}, which itself wraps innerErr
err := fmt.Errorf("wrapped: %w", &Error{
Err: innerErr,
Type: ErrorTypeAny,
})
// check that 'errors.Is()' and 'errors.As()' behave as expected :
require.ErrorIs(t, err, innerErr)
var testErr TestErr
require.ErrorAs(t, err, &testErr)
// Test non-pointer usage of gin.Error
errNonPointer := Error{
Err: innerErr,
Type: ErrorTypeAny,
}
wrappedErr := fmt.Errorf("wrapped: %w", errNonPointer)
// Check that 'errors.Is()' and 'errors.As()' behave as expected for non-pointer usage
require.ErrorIs(t, wrappedErr, innerErr)
var testErrNonPointer TestErr
require.ErrorAs(t, wrappedErr, &testErrNonPointer)
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does TestErrorUnwrap() do?
TestErrorUnwrap() is a function in the gin codebase, defined in errors_test.go.
Where is TestErrorUnwrap() defined?
TestErrorUnwrap() is defined in errors_test.go at line 116.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free