本文整理汇总了PHP中Illuminate\Foundation\Exceptions\Handler类的典型用法代码示例。如果您正苦于以下问题:PHP Handler类的具体用法?PHP Handler怎么用?PHP Handler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Handler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
}
return parent::render($request, $e);
/* COMMENT ABOVE AND UNCOMMENT BELOW TO REDIRECT FOR CUSTOM ERROR HANDLING */
/* if ($this->isHttpException($e)) {
switch ($e->getStatusCode()) {
// not found
case 404:
die("404 Redirect to Page not found here in app/Exceptions/Handler.php");
return redirect()->guest('home');
break;
// internal error
case '500':
die("500 Redirect to internal error page here in app/Exceptions/Handler.php");
return redirect()->guest('home');
break;
default:
return $this->renderHttpException($e);
break;
}
} else {
return parent::render($request, $e);
} */
}
开发者ID:DinanathThakur,项目名称:Flash-Sale-Ecommerce-Portal-PHP,代码行数:36,代码来源:Handler.php
示例2: render
/**
* Render an exception into an HTTP response.
*
* @param Request $request
* @param Exception $exception
*
* @return Response
*/
public function render($request, Exception $exception)
{
if (!$request->is(config('jsonapi.url'))) {
return parent::render($request, $exception);
}
return $this->handle($request, $exception);
}
开发者ID:askedio,项目名称:laravel-cruddy,代码行数:15,代码来源:Handler.php
示例3: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
switch (get_class($e)) {
case "Swift_TransportException":
case "PDOException":
$errorView = "errors.500_config";
break;
case "ErrorException":
$errorView = "errors.500";
break;
case "Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException":
return abort(400);
default:
$errorView = false;
break;
}
if ($errorView) {
// This makes use of a Symfony error handler to make pretty traces.
$SymfonyDisplayer = new SymfonyDisplayer(config('app.debug'));
$FlattenException = FlattenException::create($e);
$SymfonyCss = $SymfonyDisplayer->getStylesheet($FlattenException);
$SymfonyHtml = $SymfonyDisplayer->getContent($FlattenException);
$response = response()->view($errorView, ['exception' => $e, 'error_class' => get_class($e), 'error_css' => $SymfonyCss, 'error_html' => $SymfonyHtml], 500);
return $this->toIlluminateResponse($response, $e);
} else {
return parent::render($request, $e);
}
}
开发者ID:RustyGamer,项目名称:infinity-next,代码行数:35,代码来源:Handler.php
示例4: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
switch ($e) {
case $e instanceof NotFoundHttpException:
return $this->renderException($e);
break;
case $e instanceof ModelNotFoundException:
return $this->renderException($e);
break;
case $e instanceof UnauthorizedException:
return $this->renderException($e);
break;
case $e instanceof NoActiveAccountException:
return $this->renderException($e);
break;
case $e instanceof ConnectionNotAcceptedException:
return $this->renderException($e);
break;
case $e instanceof EmailNotProvidedException:
return $this->renderException($e);
break;
case $e instanceof EmailAlreadyInSystemException:
return $this->renderException($e);
break;
case $e instanceof AlreadySyncedException:
return $this->renderException($e);
break;
case $e instanceof CredentialsDoNotMatchException:
return $this->renderException($e);
break;
default:
return parent::render($request, $e);
}
}
开发者ID:vihugarcia,项目名称:vhglaraboot,代码行数:41,代码来源:Handler.php
示例5: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof ModelNotFoundException || $e instanceof NotFoundHttpException) {
return redirect(route('dashboard'));
}
return parent::render($request, $e);
}
开发者ID:wyrover,项目名称:backendl5,代码行数:14,代码来源:Handler.php
示例6: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
}
if (config('app.debug')) {
return parent::render($request, $e);
}
if ($e instanceof TokenMismatchException) {
return redirect()->back()->withInput($request->except('_token'))->withErrors('A sua sessão expirou. Tente novamente.');
}
if (!$this->isHttpException($e)) {
$pathInfo = $request->getPathInfo();
$url = $request->url();
$method = $request->method();
$message = $e->getMessage() ?: get_class($e);
$data = ['pathInfo' => $pathInfo, 'url' => $url, 'method' => $method, 'exception' => $message, 'input' => $request->all()];
\Mail::send('emails.notify-webmaster', $data, function ($message) use($url) {
$message->from('[email protected]');
$message->to('[email protected]', 'André Ascensão');
$message->subject("Exception at {$url}");
});
}
return parent::render($request, $e);
}
开发者ID:andremiguelaa,项目名称:quiz-cascata,代码行数:32,代码来源:Handler.php
示例7: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
// LM: 09-02-2015
// See: http://stackoverflow.com/questions/29115184/laravel-catch-tokenmismatchexception
if ($e instanceof \Illuminate\Session\TokenMismatchException) {
// If the erros is a token mismatch
xplog('A token mismatch error happend', __METHOD__);
/* @BOOKMARK: TODO For now just log the user out when a token mismatch happens */
return redirect(route('logout'));
}
// See: https://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5
if ($this->isHttpException($e)) {
// See: https://laracasts.com/discuss/channels/requests/laravel-5-404-page-driving-me-crazy
switch ($e->getStatusCode()) {
case '404':
return \Response::view('errors.custom.404');
break;
/* case '500':
return \Response::view('errors.custom.500');
break; */
/* case '500':
return \Response::view('errors.custom.500');
break; */
default:
return $this->renderHttpException($e);
break;
}
}
if (config('app.debug')) {
return $this->renderExceptionWithWhoops($e);
}
return parent::render($request, $e);
}
开发者ID:rafaelgandi,项目名称:wasabi_artisan,代码行数:40,代码来源:Handler.php
示例8: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if (App::environment() == 'local') {
return parent::render($request, $e);
}
return response()->json(['error' => ['message' => $e->getMessage()]]);
}
开发者ID:Temoto-kun,项目名称:juan-n-juan,代码行数:14,代码来源:Handler.php
示例9: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof NotFoundHttpException) {
return response()->view('errors/404', [], 404);
}
return parent::render($request, $e);
}
开发者ID:minhajCSE,项目名称:teleaus-dev,代码行数:14,代码来源:Handler.php
示例10: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof ModelAlreadyExistsException) {
return redirect()->back()->withErrors([$e->getMessage()]);
}
return parent::render($request, $e);
}
开发者ID:yassinbarrani,项目名称:ThermoPiWebUI,代码行数:14,代码来源:Handler.php
示例11: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
if ($exception instanceof ValidationException && $this->isApiRoute($request)) {
return response()->error($exception->validator, 422);
}
return parent::render($request, $exception);
}
开发者ID:jadjoubran,项目名称:laravel5-angular-material-starter,代码行数:14,代码来源:Handler.php
示例12: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
//There should really be a better way to get this into json,
//but this works as well
if ($e instanceof ValidationException) {
$message = "[";
$doneOne = false;
foreach ($e->validator->messages()->all() as $err) {
if (!$doneOne) {
$doneOne = true;
} else {
$message = $message . ",";
}
$message = $message . $err . "\n";
}
$message = $message . "]";
return response($message, 400)->header("Content-Type", "application/json");
} else {
if ($e instanceof HttpException) {
if ($e->getStatusCode() == 404) {
return response(File::get(public_path() . '/index.html'));
}
return $this->renderHttpException($e);
}
}
return parent::render($request, $e);
}
开发者ID:a161527,项目名称:cs319-p2t5,代码行数:34,代码来源:Handler.php
示例13: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($request->is('webhook/*')) {
return $this->getJsonResponseForException($request, $e);
}
return parent::render($request, $e);
}
开发者ID:ngmy,项目名称:webloyer,代码行数:14,代码来源:Handler.php
示例14: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if (in_array(get_class($e), $this->dontReport)) {
return parent::render($request, $e);
}
return response()->view('errors.500', [], 500);
}
开发者ID:chrisforrence,项目名称:voxcom-solutions,代码行数:14,代码来源:Handler.php
示例15: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
/*if ($e instanceof NotFoundHttpException) {
return redirect()->route('home');
}*/
return parent::render($request, $e);
}
开发者ID:MehmetNuri,项目名称:Blog,代码行数:14,代码来源:Handler.php
示例16: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof ChainNoResultException || $e instanceof ArticleGeolocalizeException) {
return Redirect::back()->withErrors([$e->getMessage()]);
}
return parent::render($request, $e);
}
开发者ID:jahnni,项目名称:onamap,代码行数:14,代码来源:Handler.php
示例17: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($request->wantsJson()) {
return $this->responseFactory->create($e);
}
return parent::render($request, $e);
}
开发者ID:chico-rei,项目名称:restify,代码行数:14,代码来源:Handler.php
示例18: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
{
if ($exception && method_exists($exception, 'getStatusCode')) {
$code = $exception->getStatusCode();
} else {
$code = 500;
}
if (App::environment() != 'local') {
list($link_type, $link, $layout, $theme) = current_section();
View::share('current_theme', $theme);
$current_user = current_user();
if ($exception instanceof Illuminate\Database\Eloquent\ModelNotFoundException) {
return response(view("{$link_type}.{$theme}.404", array('title' => 'Page Not Found', 'current_user' => $current_user), array(404)));
}
switch ($code) {
case 401:
return response(view("{$link_type}.{$theme}.401", array('title' => 'Unauthorized access', 'current_user' => $current_user), array(401)));
break;
case 404:
return response(view("{$link_type}.{$theme}.404", array('title' => 'Page Not Found', 'current_user' => $current_user), array(404)));
break;
case 503:
return response(view('503', array('title' => 'Site Offline', 'link_type' => $link_type, 'current_user' => $current_user), array(503)));
break;
default:
return response(view("{$link_type}.{$theme}.500", array('title' => 'Error', 'current_user' => $current_user), array($code)));
break;
}
}
return parent::render($request, $exception);
}
开发者ID:doptor,项目名称:doptor,代码行数:38,代码来源:Handler.php
示例19: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if (config('app.debug') && class_exists('\\Whoops\\Run')) {
return $this->renderExceptionWithWhoops($e);
}
return parent::render($request, $e);
}
开发者ID:ladhadha,项目名称:Platform,代码行数:14,代码来源:Handler.php
示例20: render
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof ModelNotFoundException) {
abort(404);
}
return parent::render($request, $e);
}
开发者ID:atofa,项目名称:atofaVersionFinale,代码行数:14,代码来源:Handler.php
注:本文中的Illuminate\Foundation\Exceptions\Handler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论