本文整理汇总了PHP中ErrorHandler::setRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorHandler::setRequest方法的具体用法?PHP ErrorHandler::setRequest怎么用?PHP ErrorHandler::setRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorHandler
的用法示例。
在下文中一共展示了ErrorHandler::setRequest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testNotFoundPageShowsCorrectCopyWhenVerboseErrorsDisabled
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);
}
示例2: getenv
$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());
}
示例3: handle
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);
}