/** * Handle exceptions thrown during initialization or execution of the show method. * * @param \Exception $exception * * @return void */ public static function handleException(\Exception $exception) { if ($exception instanceof \FeM\sPof\exception\NotAuthorizedException) { static::sendForbidden(); } elseif ($exception instanceof \FeM\sPof\exception\UnsupportedRequestMethod) { static::sendMethodNotAllowed($exception->getAllowed()); } elseif ($exception instanceof \FeM\sPof\exception\BadRequestException) { header('Content-type: application/json'); echo json_encode(['error' => $exception->getMessage()]); static::sendBadRequest(); } header('Content-type: application/json'); echo json_encode(['msg' => $exception->getMessage(), 'exception' => $exception]); static::sendInternalError(); }