A custom error is your own error type (usually a struct) that implements `Error() string`. It may include extra fields (code, operation, resource ID, etc.).
package main import "fmt" type NotFoundError struct { Resource string ID string } func (e *NotFoundError) Error() string { return fmt.Sprintf("%s not found: %s", e.Resource, e.ID) }