feat(xerrors)!: promote to v1.0.0 — add Unauthorized and PermissionDenied constructors

Add Unauthorized and PermissionDenied convenience constructors to complete the
set of the five most-used error codes (InvalidInput, NotFound, Internal,
Unauthorized, PermissionDenied). All roadmap items from v0.9.0 resolved.
API committed as stable.
This commit is contained in:
2026-05-11 17:49:52 -06:00
parent 5381bccbf7
commit c6ff8d0a3f
3 changed files with 50 additions and 0 deletions

View File

@@ -67,6 +67,18 @@ func Internal(msg string, args ...any) *Err {
return New(ErrInternal, fmt.Sprintf(msg, args...))
}
// Unauthorized creates an Err with [ErrUnauthorized] code.
// msg is formatted with args using [fmt.Sprintf] rules.
func Unauthorized(msg string, args ...any) *Err {
return New(ErrUnauthorized, fmt.Sprintf(msg, args...))
}
// PermissionDenied creates an Err with [ErrPermissionDenied] code.
// msg is formatted with args using [fmt.Sprintf] rules.
func PermissionDenied(msg string, args ...any) *Err {
return New(ErrPermissionDenied, fmt.Sprintf(msg, args...))
}
// WithContext adds a key-value pair to the error's context fields and returns
// the receiver for chaining. Calling it multiple times with the same key
// overwrites the previous value.