NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages

Every package exception lives in RoundlyConsulting\Approvals\Exceptions and extends ApprovalsException, itself a RuntimeException — one catch covers the whole family:

ExceptionThrown when
ClosedApprovalRequestExceptionA decision or withdrawal reaches a closed request — approved, rejected, cancelled or expired (for). Its $request property is that request.
IncompletePendingApprovalExceptionA builder decides without an actor (missingActor) or an approvable (missingApprovable).
InvalidApprovalModelExceptionA configured model class doesn’t extend the expected base model (forClass).
InvalidApprovalRequestExceptionA decision is pinned to another subject’s request (foreignSubject); a request builder gets both from() and stages() (mixedApprovers); an approver is unsaved (unsavedApprover); a request needs more approvals than it names (moreRequiredThanNamed); a quorum is below 1 (thresholdBelowOne) or out of the approvers’ reach (unreachableThreshold).
InvalidDelegationExceptionSelf-delegation (selfDelegation) or a window that ends before it starts (endsBeforeStart).
InvalidStatusTransitionExceptionAn illegal status transition on the Approval model (between).
UnauthorizedApprovalExceptionThe authorization gate denies the actor (forActor), or the actor is not a named approver of the request or its open stage, nor a delegate of one (notAnApprover).
UnknownWorkflowExceptionA workflow preset is missing (named) or malformed (invalid).
use RoundlyConsulting\Approvals\Exceptions\ApprovalsException;
use RoundlyConsulting\Approvals\Exceptions\ClosedApprovalRequestException;
use RoundlyConsulting\Approvals\Exceptions\UnauthorizedApprovalException;
use RoundlyConsulting\Approvals\Facades\Approvals;

try {
    Approvals::for($post)->as($user)->approve();
} catch (UnauthorizedApprovalException $e) {
    // the gate denied this actor, or the request does not name it
} catch (ClosedApprovalRequestException $e) {
    // the round is over — $e->request is the closed request
} catch (ApprovalsException $e) {
    // any other approvals error
}

Each exception is built by the named static factory shown in brackets above, which is handy when you assert messages in tests.

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.