private function handleException(\Exception $e, $request, $type) { if (null === $this->view) { $this->view = new View\JSON($request); // fallback view instantiates error handler } return $this->view->getExceptionResponse($e); }