Warden
1.x
Docs/Warden/Errors
Open

Reading1 min
Updated31 Jul 2026
Sourcev1/concepts/errors.mdx

Warden defines sentinel errors for all failure cases. Use errors.Is() to check for specific errors.

Store Errors01

ErrorDescription
ErrNotFoundEntity not found in store
ErrAlreadyExistsEntity with same unique key already exists
ErrStoreUnavailableStore backend is not reachable
ErrMigrationFailedDatabase migration failed

Authorization Errors02

ErrorDescription
ErrAccessDeniedAuthorization check returned deny
ErrMissingSubjectCheck request has no subject
ErrMissingActionCheck request has no action
ErrMissingResourceCheck request has no resource type

Tenant Errors03

ErrorDescription
ErrMissingTenantNo tenant ID in context
ErrMissingAppIDNo app ID in context

Entity Errors04

ErrorDescription
ErrInvalidIDTypeID is malformed or has wrong prefix
ErrInvalidEffectPolicy effect is not "allow" or "deny"
ErrMaxDepthReachedReBAC graph traversal exceeded max depth
ErrCycleDetectedReBAC graph contains a cycle

Usage05

import "github.com/xraph/warden"

err := store.GetRole(ctx, roleID)
if errors.Is(err, warden.ErrNotFound) {
    // Role doesn't exist
}

result, err := eng.Check(ctx, req)
if errors.Is(err, warden.ErrMissingTenant) {
    // Forgot to set tenant context
}

HTTP Error Mapping06

When using the REST API, errors are mapped to HTTP status codes:

ErrorHTTP Status
ErrNotFound404 Not Found
ErrAlreadyExists409 Conflict
ErrAccessDenied403 Forbidden
ErrMissingSubject/Action/Resource400 Bad Request
ErrMissingTenant400 Bad Request
ErrInvalidID400 Bad Request
ErrStoreUnavailable503 Service Unavailable