Renders the response for the exception.

@return \Cake\Http\Response The response to be sent.
550102
public function render()
    {
        $exception = $this->error;
        $code = $this->_code($exception);
        $method = $this->_method($exception);
        $template = $this->_template($exception, $method, $code);
        $unwrapped = $this->_unwrap($exception);

        if (method_exists($this, $method)) {
            return $this->_customMethod($method, $unwrapped);
        }

        $message = $this->_message($exception, $code);
        $url = $this->controller->getRequest()->getRequestTarget();
        $response = $this->controller->getResponse();

        if ($exception instanceof CakeException) {
            foreach ((array)$exception->responseHeader() as $key => $value) {
                $response = $response->withHeader($key, $value);
            }
        }
        $response = $response->withStatus($code);

        $viewVars = [
            'message' => $message,
            'url' => h($url),
            'error' => $unwrapped,
            'code' => $code,
            '_serialize' => ['message', 'url', 'code']
        ];

        $isDebug = Configure::read('debug');
        if ($isDebug) {
            $viewVars['trace'] = Debugger::formatTrace($unwrapped->getTrace(), [
                'format' => 'array',
                'args' => false
            ]);
            $viewVars['file'] = $exception->getFile() ?: 'null';
            $viewVars['line'] = $exception->getLine() ?: 'null';
            $viewVars['_serialize'][] = 'file';
            $viewVars['_serialize'][] = 'line';
        }
        $this->controller->set($viewVars);

        if ($unwrapped instanceof CakeException && $isDebug) {
            $this->controller->set($unwrapped->getAttributes());
        }
        $this->controller->response = $response;

        return $this->_outputMessage($template);
    }
1035787
protected function respond($exception)
    {
        $renderer = $this->app->renderer->getRenderer($this->engine);

        $body = $renderer->render(
            $this->app->get('error.template', 'windwalker.error.default'),
            ['exception' => $exception]
        );

        $code = $exception->getCode();

        if ($code < 400 || $code >= 500) {
            $code = 500;
        }

        $response = (new HtmlResponse($body))->withStatus($code);

        $this->app->server->getOutput()->respond($response);
    }
519220
public function generateResponse()
    {
        $exception = $this->getException();
        return sprintf(
            "%s: %s in file %s on line %d%s\n",
            get_class($exception),
            $exception->getMessage(),
            $exception->getFile(),
            $exception->getLine(),
            $this->getTraceOutput()
        );
    }
1240773
public function toResponse(): Response
    {
        return new Response(
            $this->status,
            $this->headers,
            $this->body,
            $this->httpVersion,
            $this->reason
        );
    }
691179
public function exceptionAction() {
		
		// get the exception
		$this->Exception = Store\Request::get('exception');
		// if the exception is not a 404 or a 403 (the most common and non important)
		if(
			$this->Exception->getCode() < 401 || 
			$this->Exception->getCode() > 404
		) {
			// log the exception
			Logger::critical(
				$this->Exception->getCode() . ' '.
				$this->Exception->getMessage(), 
				$this->Exception->getTrace()
			);
		}
		// error occured while requesting something else than html
		if(!in_array(
			Response::getType(), 
			['html','html-page']
		)) {
			// change the type to plaintext
			Response::setType('text');
			// set the stack a string
			Response::setContent(
				$this->Exception->getCode() . "\n".
				$this->Exception->getMessage() . "\n".
				$this->Exception
			);
			// render as is
			Response::render();
		}
		// error occured normally
		else {
			// disable space removal for the trace stack
			Config::set('response','minify', 0);
			// reset already output data (very important, because of content-length)
			Response::setType('html-page');
			// proper title and assets
			Response\HTML::set([
				'metas'		=>[
					'title'=> $this->Exception->getCode() . ', ' . 
						Locales::get($this->Exception->getMessage())
				],
				'scripts'	=>[
					'//code.jquery.com/jquery-3.3.1.slim.min.js',
					'//stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js'
				],
				'links'		=>[
					'//stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css',
					'//use.fontawesome.com/releases/v5.3.1/css/all.css'
				]
			]);
			
			// error is of type forbidden/bad request
			if(
				$this->Exception->getCode() >= 400 && 
				$this->Exception->getCode() <= 403
			) {
				$this->icon = 'fa fa-ban';
			}
			// error is of type internal error
			elseif(
				$this->Exception->getCode() >= 500 && 
				$this->Exception->getCode() <= 599
			) {
				$this->icon = 'fa fa-bug';
			}
			// error is not found
			elseif(
				$this->Exception->getCode() == 404
			) {
				$this->icon = 'fa fa-exclamation-circle';
			}
			// any other type of errors
			else {
				$this->icon = 'fa fa-exclamation-triangle';
			}

			// pass to the exception view
			$this->view('Exception');
		}
			
	}
826800
public function build() : Response {
		$view_root      = '';
		$template_name  = $this->get_template_name();
		$file_extension = $this->get_file_extension( $view_root, $template_name );
		$view_data      = $this->view_data;
		$content        = '';

		if ( 'handlebars' === $file_extension ) {
			$view = new Simple_Handlebars_View(
				$view_root,
				$template_name,
				function ( $engine ) use ( $template_name, $view_data ) {
						return $engine->render(
							$template_name,
							$view_data
						);
				},
				$this->path_to_views
			);
			$content = $view->output();
		}

		return new Response(
			array(
				'content' => $content,
				'head'    => $this->head_data,
			)
		);
	}
280918
function Render()
    {
        self::$currentPage = $this->page;
        self::$Title = self::$currentPage->GetTitle();
        self::$Description = self::$currentPage->GetDescription();
        self::$Keywords = self::$currentPage->GetKeywords();
        if ($this->page->GetType() == (string)PageType::NotFound())
        {
            header('HTTP/1.0 404 Not Found');
        }
        else if ($this->page->GetType() !== (string)PageType::Normal())
        {
            throw new \Exception('Internal phine error: not normal page called');
        }
        ob_start();
        require PathUtil::LayoutTemplate($this->layout);
        $result = ob_get_clean();
        $replacer = new Replacer();
        return $replacer->RealizeVariables($result);
    }
741246
protected function _exception() {
        $url = '.' . $this->request->src . '.' . $this->request->controller . '.' . $this->request->action;

        if (in_array($url, $this->config['user']['security']['spam']['config']['exception'])) {
            $this->_exception = true;
        }

        return $this->_exception;
    }
1335448
public function processResponse()
    {
        // Holds the results
        $results = [];

        // Iterate over the packets
        foreach ($this->packets_response as $response) {
            // Make a buffer
            $buffer = new Buffer($response);

            // Grab the header
            $header = $buffer->readString();

            // Figure out which packet response this is
            if (!array_key_exists($header, $this->responses)) {
                throw new Exception(__METHOD__ . " response type '" . bin2hex($header) . "' is not valid");
            }

            // Now we need to call the proper method
            $results = array_merge(
                $results,
                call_user_func_array([$this, $this->responses[$header]], [$buffer])
            );
        }

        unset($buffer);

        return $results;
    }
1266883
protected function render()
    {
        $body = $this->view->__invoke();
        $this->response->getBody()->write($body);
    }
47253
public function display(Exception $exception)
	{
		$status = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : 500;

		return new Response($this->whoops->handleException($exception), $status);
	}
966003
public function render($request, Exception $e)
	{
		if ($e instanceof HttpException) {
			$response = $e->response();
			
			if ($request->header('Origin')) {
				Cors::attachHeaders($response);
				$response->headers->set('Access-Control-Allow-Origin', $request->header('Origin'));
			}
			
			return $response;
		}
		
		return parent::render($request, $e);
	}
844508
public function handler(): Response
    {
        $response = [];
        foreach (Bulletin::all() as $bulletin) {
            $response[] = [
                'id' => $bulletin->getId(),
                'createdAt' => $bulletin->getCreatedAt()->getTimestamp(),
                'title' => $bulletin->getTitle(),
                'abstract' => $bulletin->getAbstract(),
                'isDraft' => $bulletin->isDraft(),
                'statistics' => $bulletin->getStatistics()
            ];
        }
        return response($response);
    }
249841
public function httpResponse()
    {
        // get the template
        $template = $this->view()->getTemplate();

        // if there is no template, then we return false
        if(empty($template)) {
            return false;
        }

        // get view data
        $viewData = $this->view()->getAssignedData();

        // assign application data to view
        $viewData['App'] = [
            'Config'       => $this->getEnvironmentConfig(),
            'Components'   => $this->environment->getComponentConfigs()->toArray(),
            'Environment'  => $this->getEnvironmentName(),
            'AbsolutePath' => $this->getAbsolutePath(),
            'WebPath'      => $this->getWebPath()
        ];

        // render the view and assign it to the response object
        return new Response($this->getTemplateEngineInstance()->fetch($this->view()->getTemplate(), $viewData));
    }
1118111
public function render()
    {
        if ($this->isAjax()) {
            if ($this->isExport()) {

                if (!$this->getExportable()) {
                    throw new \Exception('Export not allowed');
                }

                $data = $this->processExport();
            } else {
                $data = $this->processGrid();
            }

            $json = json_encode($data);

            $response = new Response();
            $response->headers->set('Content-Type', 'application/json');
            $response->setContent($json);

            return $response;
        } else {
            if ($this->isExport()) {

                if (!$this->getExportable()) {
                    throw new \Exception('Export not allowed');
                }

                $exportFile = $this->getExportFileName();

                $response = new Response();
                $response->headers->set('Content-Type', 'text/csv');
                $response->headers->set('Content-Disposition', 'attachment; filename="' . basename($exportFile) . '"');
                $response->setContent(file_get_contents($exportFile));

                return $response;
            } else {
                return new GridView($this, $this->container);
            }
        }
    }
686047
public function prepareResponse()
    {
        try {
            $this->setBaseMiddlewares();
            $this->handleRequest($this->middlewares);
            $this->router->build();
            $this->handleRequest($this->routeMiddlewares);
            $this->response = $this->router->run();
        } catch (Exception $exception) {
            $response = $this->container->call([$this->getExceptionHandler(), 'render'], [$exception]);
            $this->response = $response ?: $this->response;
        }
    }
467351
public function render()
    {
        $responseData = array(
            "status" => $this->_statusCode,
            "body"   => $this->_content,
            "errors" => $this->_errors
        );
        
        return json_encode($responseData);
    }