Skip to main content

Error Reference

AUSUS uses a small, explicit exception taxonomy. Every kernel error extends one base class, so you can catch broadly or narrowly.

The base class

class AususError extends \RuntimeException {}

Every error below extends Ausus\AususError. Catching AususError catches all of them; the runtime distinguishes an AUSUS error from an unexpected one (an unexpected error thrown inside an effect is wrapped as EffectFailed).

Kernel exceptions

ExceptionRaised when
UnknownActioninvoke() is given an action FQN not in the graph
PolicySubjectRequiredan action needs a subject but none was passed
ActorRequiredan actor is required but absent
TenantContextRequireda tenant context is required but absent
TenantBoundaryViolationa Reference's tenant differs from the active tenant
PolicyDeniedthe policy returned a non-Permit decision
WorkflowStateMismatchno transition allows the action from the current state
WorkflowSubjectNotFoundthe workflow subject record does not exist
WorkflowGuardDenieda workflow guard refused the transition
EffectFailedan effect threw; carries the underlying cause
ConcurrencyConflictan update was attempted with a stale _version
NotFounda referenced record does not exist
AuditEmissionFailedthe audit sink rejected the audit entry

ConcurrencyConflict and NotFound carry the offending Reference; ConcurrencyConflict also carries the expected and actual versions.

HTTP mapping

ausus/api-http adds one transport-level exception, BadRequest, and maps the taxonomy to HTTP status codes via ErrorMapper:

ExceptionHTTP statuserror.kind
BadRequest400BadRequest
MalformedDescriptor400MalformedDescriptor
PolicyDenied403PolicyDenied
TenantBoundaryViolation403TenantBoundaryViolation
WorkflowStateMismatch409WorkflowStateMismatch
ConcurrencyConflict409ConcurrencyConflict
EffectFailure500EffectFailure
anything else500InternalError

The HTTP error envelope:

{ "ok": false, "error": { "kind": "WorkflowStateMismatch", "message": "..." } }

Catching errors

use Ausus\{PolicyDenied, WorkflowStateMismatch, ConcurrencyConflict, AususError};

try {
$invoker->invoke('billing.invoice.issue', $ref, []);
} catch (PolicyDenied $e) {
// actor lacks the required role
} catch (WorkflowStateMismatch $e) {
// the invoice is not in a state that allows `issue`
} catch (ConcurrencyConflict $e) {
// someone else changed the record — re-read and retry
} catch (AususError $e) {
// any other AUSUS error
}

Current v0.1.0 limitations

  • The taxonomy is intentionally minimal. It is described in the source as a "V0 minimal closed-ish taxonomy" — later versions may add finer-grained errors.
  • Errors carry a message and (for some) a Reference; there is no structured error-code catalogue or i18n of error messages in v0.1.0.