-
Notifications
You must be signed in to change notification settings - Fork 96
Open
Description
Is it possible to throw an exception in a controller method and catch that in the dispatcher/router? Controller methods are called in the Dispatcher using call_user_func_array, which doesn't allow for catching exceptions.
If not, how else would you return early from a method?
class MyController {
public function anyIndex() {
$this->checkAccess('edit');
}
private function checkAccess($permission) {
if ($userPermission != $permission) throw new Exception("You don't have permission", 401);
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels