Documentation ¶
Index ¶
- Constants
- func CombineMetadata(withMetadata WithMetadata, metadata map[string]string) map[string]string
- func ForReason(reason v1.ErrorReason, metadata map[string]string) *errdetails.ErrorInfo
- func MustBugf(format string, args ...any) error
- func MustPanic(format string, args ...any)
- func RequireReason(t testing.TB, reason v1.ErrorReason, err error, expectedMetadataKeys ...string)
- func WithCodeAndDetails(err error, code codes.Code, details ...protoiface.MessageV1) *status.Status
- func WithCodeAndReason(err error, code codes.Code, reason v1.ErrorReason) error
- type ErrorWithSource
- type HasMetadata
- type SourcePosition
- type WithMetadata
Constants ¶
const Domain = "authzed.com"
Domain is the domain used for all errors.
Variables ¶
This section is empty.
Functions ¶
func CombineMetadata ¶ added in v1.16.2
func CombineMetadata(withMetadata WithMetadata, metadata map[string]string) map[string]string
CombineMetadata combines the metadata found on an existing error with that given.
func ForReason ¶
func ForReason(reason v1.ErrorReason, metadata map[string]string) *errdetails.ErrorInfo
ForReason returns an ErrorInfo block for a specific error reason as defined in the V1 API.
func MustBugf ¶ added in v1.16.0
MustBugf returns an error representing a bug in the system. Will panic if run under testing.
func MustPanic ¶ added in v1.16.0
MustPanic is a special function for panicing when necessary to violate the linter.
func RequireReason ¶
RequireReason asserts that an error is a gRPC error and returns the expected reason in the ErrorInfo. TODO(jschorr): Move into grpcutil.
func WithCodeAndDetails ¶
WithCodeAndDetails returns a gRPC status message containing the error's message, the given status code and any supplied details.
func WithCodeAndReason ¶
WithCodeAndReason returns a new error which wraps the existing error with a gRPC code and a reason block.
Types ¶
type ErrorWithSource ¶
type ErrorWithSource struct { // SourceCodeString is the input source code string for the error. SourceCodeString string // LineNumber is the (1-indexed) line number of the error, or 0 if unknown. LineNumber uint64 // ColumnPosition is the (1-indexed) column position of the error, or 0 if // unknown. ColumnPosition uint64 // contains filtered or unexported fields }
ErrorWithSource is an error that includes the source text and position information.
func AsErrorWithSource ¶
func AsErrorWithSource(err error) (*ErrorWithSource, bool)
AsErrorWithSource returns the error as an ErrorWithSource, if applicable.
func NewErrorWithSource ¶
func NewErrorWithSource(err error, sourceCodeString string, oneIndexedLineNumber uint64, oneIndexedColumnPosition uint64) *ErrorWithSource
NewErrorWithSource creates and returns a new ErrorWithSource.
func (*ErrorWithSource) Unwrap ¶
func (err *ErrorWithSource) Unwrap() error
Unwrap returns the inner, wrapped error.
type HasMetadata ¶
type HasMetadata interface { // DetailsMetadata returns the metadata for details for this error. DetailsMetadata() map[string]string }
HasMetadata indicates that the error has metadata defined.
type SourcePosition ¶
type SourcePosition struct { // LineNumber is the 1-indexed line number in the input source. LineNumber int // ColumnPosition is the 1-indexed column position in the input source. ColumnPosition int }
SourcePosition is a position in the input source.