Exemplo n.º 1
0
 /**
  * Render the given HttpException.
  *
  * @param  \Symfony\Component\HttpKernel\Exception\HttpException  $e
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     if (view()->exists('errors.' . $e->getStatusCode())) {
         return response()->view('errors.' . $e->getStatusCode(), [], $e->getStatusCode());
     } else {
         return (new SymfonyDisplayer(config('app.debug')))->createResponse($e);
     }
 }
Exemplo n.º 2
0
 /**
  * Render the given HttpException.
  *
  * @param  \Symfony\Component\HttpKernel\Exception\HttpException $e
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     // load base JS
     JavaScript::put(['base_url' => url('/'), 'site_name' => config('settings.app_name_' . config('app.locale'))]);
     $seo_meta = ['page_title' => 'Erreur ' . $e->getStatusCode(), 'meta_desc' => $e->getMessage(), 'meta_keywords' => ''];
     $data = ['code' => $e->getStatusCode(), 'seo_meta' => $seo_meta, 'css' => elixir('css/app.error.css')];
     return response()->view('templates.common.errors.errors', $data);
 }
Exemplo n.º 3
0
 /**
  * Render the given HttpException.
  *
  * @param  \Symfony\Component\HttpKernel\Exception\HttpException  $e
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     if (view()->exists('errors.' . $e->getStatusCode())) {
         return response()->view('errors.' . $e->getStatusCode(), ['message' => $e->getMessage(), 'trace' => $e->getTraceAsString(), 'debug' => config('app.debug')], $e->getStatusCode());
     } else {
         return (new SymfonyDisplayer(config('app.debug')))->createResponse($e);
     }
 }
Exemplo n.º 4
0
 /**
  * 自定义错误页
  */
 protected function renderHttpException(HttpException $e)
 {
     if (Request::ajax() and !config('app.debug')) {
         return responseJson($e->getStatusCode(), false);
     } elseif (view()->exists('error.common') and !config('app.debug')) {
         return response()->view('error.common', ['errorCode' => $e->getStatusCode()], $e->getStatusCode());
     } else {
         return (new SymfonyDisplayer(config('app.debug')))->createResponse($e);
     }
 }
Exemplo n.º 5
0
 /**
  * Handle not found exception.
  *
  * @param  \Symfony\Component\HttpKernel\Exception\HttpException $e
  *
  * @return mixed
  */
 public function handle(HttpException $e)
 {
     $errorViewName = 'errors.' . $e->getStatusCode();
     // Here we check whether view is exist. For example if you got 404 status,
     // then we need a `errors.404` view file. If it exists, we render that view,
     // otherwise, we just throw back the exception, leaving it uncaught.
     if (View::exists($errorViewName)) {
         return Response::make(View::make($errorViewName, ['error' => $e]), $e->getStatusCode())->send();
     }
     throw $e;
 }
Exemplo n.º 6
0
 function it_prepares_http_exceptions(HttpException $httpException)
 {
     $httpException->getStatusCode()->willReturn(404);
     $httpException->getHeaders()->willReturn(['Header:test']);
     $this->handleException($httpException);
     $this->sendHttpCode()->shouldReturn(404);
     $this->headers()->shouldReturn(['Header:test']);
 }
Exemplo n.º 7
0
 /**
  * Render the given HttpException.
  *
  * @param  \Symfony\Component\HttpKernel\Exception\HttpException  $e
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     if (view()->exists(config('smile.theme') . '::' . "errors.{$status}")) {
         return response()->view(config('smile.theme') . '::' . "errors.{$status}", [], $status);
     }
     return (new SymfonyDisplayer(config('app.debug')))->createResponse($e);
 }
Exemplo n.º 8
0
 /**
  * Render the given HttpException.
  *
  * @param  \Symfony\Component\HttpKernel\Exception\HttpException  $e
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     if (view()->exists("errors.{$status}")) {
         return response()->view("errors.{$status}", ['message' => $e->getMessage()], $status);
     }
     return parent::renderHttpException($e);
 }
Exemplo n.º 9
0
 /**
  * Render the given HttpException.
  *
  * @param HttpException $e
  *
  * @return \Illuminate\Http\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $code = $e->getStatusCode();
     $default_config = ['title' => 'エラーが発生しました。', 'msg' => 'エラーが発生しました。'];
     $error_set = config("errors.{$code}", $default_config);
     $data = array_merge($error_set, ['exception' => $e]);
     return response()->view('errors.all', $data, $code);
 }
 protected function convertHttpExceptionToJsonResponse(HttpException $exc)
 {
     $data = json_decode($exc->getMessage(), true);
     if (!is_array($data)) {
         $data = ['_message' => $exc->getMessage()];
     }
     return new JsonResponse($data, $exc->getStatusCode());
 }
Exemplo n.º 11
0
 /**
  * Render the given HttpException.
  *
  * @param  \Symfony\Component\HttpKernel\Exception\HttpException  $e
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     if (view()->exists("csm::errors.{$status}")) {
         return response()->view("errors.{$status}", ['message' => $e->getMessage(), 'line' => $e->getLine(), 'file' => $e->getFile(), 'code' => $status, 'bodyId' => 'error.' . $status], $status);
     } else {
         return (new SymfonyDisplayer(config('app.debug')))->createResponse($e);
     }
 }
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     if (view()->exists($this->pathErrors . $status)) {
         return response()->view($this->pathErrors . $status, ['exception' => $e], $status, $e->getHeaders());
     } else {
         return parent::renderHttpException($e);
     }
 }
Exemplo n.º 13
0
 /**
  * Render the given HttpException.
  *
  * @param  HttpException $e
  * @return Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     if (view()->exists("errors.{$status}")) {
         return response(view("errors.{$status}"), $status);
     } else {
         return (new SymfonyExceptionHandler(env('APP_DEBUG')))->createResponse($e);
     }
 }
Exemplo n.º 14
0
 /**
  * Функция для отображения сообщений на страницах ошибок (404, 500 etc.)
  * @param HttpException $e
  * @return \Illuminate\Http\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     if (view()->exists("errors.{$status}")) {
         return response()->view("errors.{$status}", ['message' => $e->getMessage(), 'status' => $status, 'headers' => $e->getHeaders()], $status);
     } else {
         return $status;
     }
 }
Exemplo n.º 15
0
 /**
  * Render the given HttpException.
  *
  * @param  \Symfony\Component\HttpKernel\Exception\HttpException  $e
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     if (view()->exists("jplatformui::errors.{$status}")) {
         return response()->view("jplatformui::errors.{$status}", ['exception' => $e], $status);
     } else {
         return $this->convertExceptionToResponse($e);
     }
 }
Exemplo n.º 16
0
 /**
  * Render the given HttpException.
  *
  * @param  \Symfony\Component\HttpKernel\Exception\HttpException $e
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     if (view()->exists("soda-example::errors.{$status}")) {
         return response()->view("soda-example::errors.{$status}", ['exception' => $e], $status, $e->getHeaders());
     } else {
         return response()->view("soda-example::errors.other", ['exception' => $e], $status, $e->getHeaders());
     }
 }
Exemplo n.º 17
0
 /**
  * Render a HTTP exception, including a custom error message.
  *
  * @param  \HttpException  $e
  * @return \Illuminate\Http\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     if (!config('app.debug') && view()->exists("errors.{$status}")) {
         return response()->view("errors.{$status}", compact('e'), $status);
     } else {
         return (new SymfonyDisplayer(config('app.debug')))->createResponse($e);
     }
 }
Exemplo n.º 18
0
 /**
  * Render the given HttpException.
  *
  * @param  \Symfony\Component\HttpKernel\Exception\HttpException $e
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     if (!config('app.debug') && view()->exists("streams::errors.{$status}")) {
         return response()->view("streams::errors.{$status}", ['message' => $e->getMessage()], $status);
     } else {
         return (new SymfonyDisplayer(config('app.debug')))->handle($e);
     }
 }
Exemplo n.º 19
0
 /**
  * 自定义错误,如果view/errors/ 下存在错误模板,就显示错误模板。
  * @param $request
  * @param HttpException $e
  * @return \Laravel\Lumen\Http\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException($request, HttpException $e)
 {
     $status = $e->getStatusCode();
     if (view()->exists("errors.{$status}")) {
         return response(view("errors.{$status}", []), $status);
     } else {
         return parent::render($request, $e);
     }
 }
Exemplo n.º 20
0
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     if (view()->exists("errors.{$status}")) {
         return response()->view("errors.{$status}", [], $status);
     } else {
         return response()->view("errors.default", [], $status);
     }
 }
Exemplo n.º 21
0
 /**
  * Render the given HttpException.
  *
  * @param  \Symfony\Component\HttpKernel\Exception\HttpException  $e
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     if (view()->exists("public::errors.{$status}")) {
         $theme = Theme::uses('public')->layout('error');
         return $theme->of("public::errors.{$status}", ['exception' => $e])->render();
     } else {
         return $this->convertExceptionToResponse($e);
     }
 }
Exemplo n.º 22
0
 /**
  * Render the given HttpException.
  *
  * @param  \Symfony\Component\HttpKernel\Exception\HttpException  $e
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     $view = $e->context !== Application::CXT_SITE ? "cms::errors." . $status : "errors." . $status;
     if (view()->exists($view)) {
         return response()->view($view, ['exception' => $e], $status);
     } else {
         return $this->convertExceptionToResponse($e);
     }
 }
Exemplo n.º 23
0
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     if (view_exists("errors.{$status}")) {
         $viewData = ['app_env' => env('APP_ENV'), 'app_version' => config('app.version'), 'app_title' => config('app.title'), 'site_name' => config('app.site_name'), 'scripts' => ['jquery.js', 'jquery-ui.min.js', 'foundation.min.js', 'tag-it.min.js', 'app.js'], 'modules' => \Module::slugs(), 'exception' => $e];
         return response()->view("errors.{$status}", $viewData, $status);
     } else {
         return $this->convertExceptionToResponse($e);
     }
 }
Exemplo n.º 24
0
 /**
  * Render the given HttpException.
  *
  * @param  \Symfony\Component\HttpKernel\Exception\HttpException  $e
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     $env = \App::environment();
     if (view()->exists("errors.{$status}") && $env != KACANA_ENVIRONMENT_DEVELOPMENT) {
         return response()->view("errors.{$status}", [], $status);
     } else {
         return (new SymfonyDisplayer(config('app.debug')))->createResponse($e);
     }
 }
Exemplo n.º 25
0
 /**
  * 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 NotosException) {
         $e = new HttpException($e->getStatus(), $e->getMessage(), $e->getPrevious(), [], $e->getCode());
         $response = new JsonResponse($e->getMessage(), $e->getStatusCode(), []);
         $response->exception = $e;
         return $response;
     }
     if ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     }
     return parent::render($request, $e);
 }
 /**
  * Asserts if page was redirected correctly
  *
  * @param $location Location where it should be redirected
  * @return void
  */
 public function assertRedirection($location = null)
 {
     $response = $this->client->getResponse();
     if ($this->lastException) {
         $statusCode = $this->lastException->getStatusCode();
     } else {
         $statusCode = $response->getStatusCode();
     }
     $isRedirection = in_array($statusCode, array(201, 301, 302, 303, 307, 308));
     $this->assertTrue($isRedirection, "Last request was not a redirection. Status code was " . $statusCode);
     if ($location) {
         if (!strpos($location, '://')) {
             $location = 'http://:' . $location;
         }
         $this->assertEquals($this->cleanTrailingSlash($location), $this->cleanTrailingSlash($response->headers->get('Location')), 'Page was not redirected to the correct place');
     }
 }
 /**
  * Handle an exception and display the correct error message. Firstly check
  * for a errorXXX.format.twig file, otherwise default to error.html.twig
  * @param GetResponseEvent $event
  * @param HttpException $exception
  * @param string $format
  */
 public function handle(GetResponseEvent $event, $exception, $format = 'html')
 {
     $message = $exception->getMessage();
     if ($exception instanceof HttpException) {
         $statusCode = $exception->getStatusCode();
     } elseif ($exception instanceof AccessDeniedException) {
         $statusCode = $exception->getCode();
     } else {
         $statusCode = 500;
     }
     $error = FlattenException::create($exception);
     $baseDirectory = 'AnujNairBundle:Error:';
     try {
         $renderedView = $this->template->render("{$baseDirectory}error{$statusCode}.{$format}.twig", ['statusCode' => $statusCode, 'message' => $message, 'error' => $error]);
     } catch (\Exception $e) {
         $renderedView = $this->template->render("{$baseDirectory}error.html.twig", ['statusCode' => $statusCode, 'message' => $message, 'error' => $error]);
     }
     $response = Response::create($renderedView, $statusCode);
     $event->stopPropagation();
     $event->setResponse($response);
 }
 /**
  * @param HttpException $e
  * @return ErrorInterface
  */
 protected function getHttpError(HttpException $e)
 {
     return new Error(null, null, $e->getStatusCode(), null, null, $e->getMessage() ?: null);
 }
Exemplo n.º 29
0
 /**
  * @param \Symfony\Component\HttpKernel\Exception\HttpException $exception
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException(HttpException $exception)
 {
     $status = $exception->getStatusCode();
     if ($this->view->exists("error::{$status}") && !$this->configuration->get('app.debug')) {
         return $this->response->view("error::{$status}", ['exception' => $exception], $status, $exception->getHeaders());
     } else {
         return $this->convertExceptionToResponse($exception);
     }
 }
Exemplo n.º 30
0
 /**
  * Render the given HttpException.
  *
  * @param  \Symfony\Component\HttpKernel\Exception\HttpException  $e
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     $hoje = getdate();
     $hoje2 = $hoje['year'] . '-' . $hoje['mon'] . '-' . $hoje['mday'];
     $mensagem = MensagemAdm::all()->last();
     $acaos = DB::table('acaos')->select('*')->where('data_sorteio', '>=', $hoje2)->where('deleted_at', null)->where('winner_id', null)->get();
     $criador = DB::table('users')->select('*')->join('acaos', 'users.id', '=', 'acaos.user_id')->get();
     $rifas = DB::table('rifas')->select('*')->join('users', 'rifas.user_id', '=', 'users.id')->whereNotNull('user_id')->groupby('name', 'acao_id')->get();
     if (view()->exists("errors.{$status}")) {
         return response()->view("errors.{$status}", ['exception' => $e, 'mensagem' => $mensagem, 'acaos' => $acaos, 'criador' => $criador, 'rifas' => $rifas], $status, $e->getHeaders());
     } else {
         return $this->convertExceptionToResponse($e);
     }
 }