All packages
Approvals for Laravel
Exceptions
Every package exception lives in RoundlyConsulting\Approvals\Exceptions and extends ApprovalsException, itself a RuntimeException — one catch covers the whole family:
| Exception | Thrown when |
|---|---|
ClosedApprovalRequestException | A decision or withdrawal reaches a closed request — approved, rejected, cancelled or expired (for). Its $request property is that request. |
IncompletePendingApprovalException | A builder decides without an actor (missingActor) or an approvable (missingApprovable). |
InvalidApprovalModelException | A configured model class doesn’t extend the expected base model (forClass). |
InvalidApprovalRequestException | A 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). |
InvalidDelegationException | Self-delegation (selfDelegation) or a window that ends before it starts (endsBeforeStart). |
InvalidStatusTransitionException | An illegal status transition on the Approval model (between). |
UnauthorizedApprovalException | The 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). |
UnknownWorkflowException | A 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 cryptoBy 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.