public function testNotFoundPageShowsCorrectCopyWhenVerboseErrorsDisabled() { $original = Settings::getSettings(); $settings = $original; $settings['errors']['verbose'] = false; Settings::setFromArray($settings); try { $this->request->dispatch("/notfound"); } catch (Exception $e) { $handler = new ErrorHandler(); $handler->setRequest($this->request); $handler->handleError($e); $this->assertResponseCode(404, $handler->getResponse()); $this->assertBodyHasContents("Oops! That’s a 404", $handler->getResponse()); $this->assertBodyHasContents("It looks like the page you’re after doesn’t exist", $handler->getResponse()); } Settings::setFromArray($original); }
$mode = getenv("PROJECT_MODE") !== false ? getenv("PROJECT_MODE") : "live"; //session_cache_limiter(false); try { // make sure a request object is available as soon as possible $request = JaossRequest::getInstance(); Settings::setMode($mode); include "library/boot.php"; include "library/load_apps.php"; if (Settings::getValue("date", "allow_from_cookie", false)) { $date = CookieJar::getInstance()->getCookie("test_date"); if ($date !== null) { Utils::setCurrentDate($date); } } $request->dispatch(); $response = $request->getResponse(); /* $response->setIfNoneMatch( $request->getHeader('If-None-Match') ); */ $response->send(); } catch (Exception $e) { $handler = new ErrorHandler(); $handler->setRequest($request); $handler->handleError($e); $response = $handler->getResponse(); $response->send(); } catch (Exception $e) { exit($e->getMessage()); }
function handle($request) { $this->request = $request; // // Set up to catch responses that drop outof the sky // ErrorHandler::setRequest($request); ErrorHandler::handleFatalErrors(function ($response) { $this->onErrorResponseFromHandlers($response); }); ErrorHandler::handleScriptErrors(function ($response) { $this->onErrorResponseFromHandlers($response); }); // ErrorHandler::handleExceptions(function($response){ $this->onErrorResponseFromHandlers($response); }); try { $this->doSetUp(); try { $this->doSomething(); $returnedValues = "good response"; $response = new GoodResponse($this->request, $returnedVlaues); // // Here make the doSomething response into a FULL response // } catch (Exception $exception) { $response = ErrorResponse::fromException($exception); var_dump($response); } } catch (\Exception $exception) { $response = "outter catch block"; //sendResponse($response); } $this->sendResponse($response); }