Skip to content

Exceptions

phil/listings

Every exception of the library implements Phil\Listings\Exception\ListingsException.

ExceptionExtendsThrown when
InvalidListingInvalidArgumentExceptionA value the library cannot work with: an identifier, a key, a title, a place, a criterion, a policy's bound, a minimum age, a stored listing, or a policy of another kind than the listing's.
ForbiddenTransitionLogicExceptionA listing or a response asked for a change its status does not allow; a report by the author or on a listing that is not visible; an extension past the kind's last.
UnknownKindRuntimeExceptionKindPolicies::get() asked for a kind no policy is declared for.
ResponseRefusedRuntimeExceptionThe Responder refused a response or an acceptance; its public refusal is the Refusal that says why.

The messages name the rule that failed, never the value a member typed: a refused title says how long a title may be, not what it said.

use Phil\Listings\Exception\ResponseRefused;

try {
    $responder->respond($listing, $id, $member);
} catch (ResponseRefused $refused) {
    return $this->render('listing/refused.html.twig', ['reason' => $refused->refusal->value]);
}