作者:DinanathThaku
项目:Flash-Sale-Ecommerce-Portal-PH
/**
* 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);
} */
}
作者:askedi
项目:laravel-crudd
/**
* 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);
}
作者:RustyGame
项目:infinity-nex
/**
* 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);
}
}
作者:vihugarci
项目:vhglaraboo
/**
* 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);
}
}
作者:wyrove
项目:backendl
/**
* 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);
}
作者:andremiguela
项目:quiz-cascat
/**
* 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('no-reply@andremiguelaa.com');
$message->to('andremiguelaa@gmail.com', 'André Ascensão');
$message->subject("Exception at {$url}");
});
}
return parent::render($request, $e);
}
作者:rafaelgand
项目:wasabi_artisa
/**
* 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);
}
作者:Temoto-ku
项目:juan-n-jua
/**
* 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()]]);
}
作者:minhajCS
项目:teleaus-de
/**
* 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);
}
作者:yassinbarran
项目:ThermoPiWebU
/**
* 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);
}
作者:jadjoubra
项目:laravel5-angular-material-starte
/**
* 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);
}
作者:a16152
项目:cs319-p2t
/**
* 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);
}
作者:ngm
项目:webloye
/**
* 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);
}
作者:chrisforrenc
项目:voxcom-solution
/**
* 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);
}
作者:MehmetNur
项目:Blo
/**
* 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);
}
作者:jahnn
项目:onama
/**
* 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);
}
作者:chico-re
项目:restif
/**
* 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);
}
作者:dopto
项目:dopto
/**
* 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);
}
作者:ladhadh
项目:Platfor
/**
* 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);
}
作者:atof
项目:atofaVersionFinal
/**
* 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);
}