Documentation
¶
Overview ¶
This example demonstrates how to create different types of errors using the errors package.
This example demonstrates how to categorize and handle different types of errors.
This example demonstrates how to add and retrieve context information from errors.
This example demonstrates how to wrap errors to add context as they propagate up the call stack.
This example demonstrates how to include and retrieve caller information from errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UserAPI ¶
type UserAPI struct {
// contains filtered or unexported fields
}
UserAPI simulates an API that uses the service and categorizes errors
type UserCategoryService ¶
type UserCategoryService struct {
// contains filtered or unexported fields
}
UserCategoryService uses the repository and handles errors
func NewUserCategoryService ¶
func NewUserCategoryService() *UserCategoryService
NewUserCategoryService creates a new UserCategoryService
type UserRepository ¶
type UserRepository struct{}
UserRepository simulates a user repository with potential errors
func (*UserRepository) GetUserByID ¶
func (r *UserRepository) GetUserByID(id string) (string, error)
GetUserByID simulates getting a user by ID from a database
type UserService ¶
type UserService struct{}
UserService is a simple service that demonstrates error context
func (*UserService) CreateUser ¶
func (s *UserService) CreateUser(user *User) error
CreateUser creates a user and demonstrates error context propagation
func (*UserService) ValidateUser ¶
func (s *UserService) ValidateUser(user *User) error
ValidateUser validates a user and returns an error with context if validation fails