CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • BaseErrorHandler
  • Debugger
  • ErrorHandler
  • ExceptionRenderer

Interfaces

  • ExceptionRendererInterface

Exceptions

  • FatalErrorException
  • PHP7ErrorException

Class ExceptionRenderer

Exception Renderer.

Captures and handles all unhandled exceptions. Displays helpful framework errors when debug is true. When debug is false a ExceptionRenderer will render 404 or 500 errors. If an uncaught exception is thrown and it is a type that ExceptionHandler does not know about it will be treated as a 500 error.

Implementing application specific exception rendering

You can implement application specific exception handling by creating a subclass of ExceptionRenderer and configure it to be the exceptionRenderer in config/error.php

Using a subclass of ExceptionRenderer

Using a subclass of ExceptionRenderer gives you full control over how Exceptions are rendered, you can configure your class in your config/app.php.

Cake\Error\ExceptionRenderer implements Cake\Error\ExceptionRendererInterface
Namespace: Cake\Error
Location: Error/ExceptionRenderer.php

Properties summary

  • $controller protected
    Cake\Controller\Controller
    Controller instance.
  • $error protected
    Exception
    The exception being handled.
  • $method protected
    string
    The method corresponding to the Exception this object is for.
  • $request protected
    Cake\Http\ServerRequest|null

    If set, this will be request used to create the controller that will render the error.

  • $template protected
    string
    Template to render for Cake\Core\Exception\Exception

Method Summary

  • __construct() public

    Creates the controller to perform rendering on the error response. If the error is a Cake\Core\Exception\Exception it will be converted to either a 400 or a 500 code error depending on the code used to construct the error.

  • __debugInfo() public

    Returns an array that can be used to describe the internal state of this object.

  • __get() public
    Magic accessor for properties made protected.
  • __set() public
    Magic setter for properties made protected.
  • _code() protected
    Get HTTP status code.
  • _customMethod() protected
    Render a custom error method/template.
  • _getController() protected

    Get the controller instance to handle the exception. Override this method in subclasses to customize the controller used. This method returns the built in ErrorController normally, or if an error is repeated a bare controller will be used.

  • _message() protected
    Get error message.
  • _method() protected
    Get method name
  • _outputMessage() protected
    Generate the response using the controller object.
  • _outputMessageSafe() protected

    A safer way to render error messages, replaces all helpers, with basics and doesn't call component methods.

  • _shutdown() protected
    Run the shutdown events.
  • _template() protected
    Get template for rendering exception info.
  • _unwrap() protected

    Returns the unwrapped exception object in case we are dealing with a PHP 7 Error object

  • render() public
    Renders the response for the exception.

Method Detail

__construct() public ¶

__construct( Exception $exception , Cake\Http\ServerRequest $request = null )

Creates the controller to perform rendering on the error response. If the error is a Cake\Core\Exception\Exception it will be converted to either a 400 or a 500 code error depending on the code used to construct the error.

Parameters
Exception $exception
Exception.
Cake\Http\ServerRequest $request optional null
The request - if this is set it will be used instead of creating a new one

__debugInfo() public ¶

__debugInfo( )

Returns an array that can be used to describe the internal state of this object.

Returns
array

__get() public ¶

__get( string $name )

Magic accessor for properties made protected.

Parameters
string $name
Name of the attribute to get.
Returns
mixed

__set() public ¶

__set( string $name , mixed $value )

Magic setter for properties made protected.

Parameters
string $name
Name to property.
mixed $value
Value for property.

_code() protected ¶

_code( Exception $exception )

Get HTTP status code.

Parameters
Exception $exception
Exception.
Returns
integer
A valid HTTP error status code.

_customMethod() protected ¶

_customMethod( string $method , Exception $exception )

Render a custom error method/template.

Parameters
string $method
The method name to invoke.
Exception $exception
The exception to render.
Returns
Cake\Http\Response
The response to send.

_getController() protected ¶

_getController( )

Get the controller instance to handle the exception. Override this method in subclasses to customize the controller used. This method returns the built in ErrorController normally, or if an error is repeated a bare controller will be used.

Returns
Cake\Controller\Controller
Triggers
Controller.startup $controller

_message() protected ¶

_message( Exception $exception , integer $code )

Get error message.

Parameters
Exception $exception
Exception.
integer $code
Error code.
Returns
string
Error message

_method() protected ¶

_method( Exception $exception )

Get method name

Parameters
Exception $exception
Exception instance.
Returns
string

_outputMessage() protected ¶

_outputMessage( string $template )

Generate the response using the controller object.

Parameters
string $template
The template to render.
Returns
Cake\Http\Response
A response object that can be sent.

_outputMessageSafe() protected ¶

_outputMessageSafe( string $template )

A safer way to render error messages, replaces all helpers, with basics and doesn't call component methods.

Parameters
string $template
The template to render.
Returns
Cake\Http\Response
A response object that can be sent.

_shutdown() protected ¶

_shutdown( )

Run the shutdown events.

Triggers the afterFilter and afterDispatch events.

Returns
Cake\Http\Response
The response to serve.

_template() protected ¶

_template( Exception $exception , string $method , integer $code )

Get template for rendering exception info.

Parameters
Exception $exception
Exception instance.
string $method
Method name.
integer $code
Error code.
Returns
string
Template name

_unwrap() protected ¶

_unwrap( Exception $exception )

Returns the unwrapped exception object in case we are dealing with a PHP 7 Error object

Parameters
Exception $exception
The object to unwrap
Returns
Exception|Error

render() public ¶

render( )

Renders the response for the exception.

Returns
Cake\Http\Response
The response to be sent.
Implementation of
Cake\Error\ExceptionRendererInterface::render()

Properties detail

$controller ¶

protected Cake\Controller\Controller

Controller instance.

$error ¶

protected Exception

The exception being handled.

$method ¶

protected string

The method corresponding to the Exception this object is for.

''

$request ¶

protected Cake\Http\ServerRequest|null

If set, this will be request used to create the controller that will render the error.

null

$template ¶

protected string

Template to render for Cake\Core\Exception\Exception

''
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs