CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.7 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.7
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 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

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • ErrorHandler
  • ExceptionRenderer

Exceptions

  • AclException
  • BadRequestException
  • CacheException
  • CakeBaseException
  • CakeException
  • CakeLogException
  • CakeSessionException
  • ConfigureException
  • ConsoleException
  • FatalErrorException
  • ForbiddenException
  • HttpException
  • InternalErrorException
  • MethodNotAllowedException
  • MissingActionException
  • MissingBehaviorException
  • MissingComponentException
  • MissingConnectionException
  • MissingControllerException
  • MissingDatabaseException
  • MissingDatasourceConfigException
  • MissingDatasourceException
  • MissingDispatcherFilterException
  • MissingHelperException
  • MissingLayoutException
  • MissingModelException
  • MissingPluginException
  • MissingShellException
  • MissingShellMethodException
  • MissingTableException
  • MissingTaskException
  • MissingTestLoaderException
  • MissingViewException
  • NotFoundException
  • NotImplementedException
  • PrivateActionException
  • RouterException
  • SocketException
  • UnauthorizedException
  • XmlException

Class ExceptionRenderer

Exception Renderer.

Captures and handles all unhandled exceptions. Displays helpful framework errors when debug > 1. When debug < 1 a CakeException 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 in one of a few ways:

  • Create an AppController::appError();
  • Create a subclass of ExceptionRenderer and configure it to be the Exception.renderer

Using AppController::appError();

This controller method is called instead of the default exception handling. It receives the thrown exception as its only argument. You should implement your error handling in that method.

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 core.php, with Configure::write('Exception.renderer', 'MyClass'); You should place any custom exception renderers in app/Lib/Error.

Package: Cake\Error
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/Error/ExceptionRenderer.php

Properties summary

  • $controller public
    Controller
    Controller instance.
  • $error public
    Exception
    The exception being handled.
  • $method public
    string
    The method corresponding to the Exception this object is for.
  • $template public
    string
    template to render for CakeException

Method Summary

  • __construct() public

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

  • _cakeError() protected
    Generic handler for the internal framework errors CakePHP can generate.
  • _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 CakeErrorController normally, or if an error is repeated a bare controller will be used.

  • _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.

  • error400() public
    Convenience method to display a 400 series page.
  • error500() public
    Convenience method to display a 500 page.
  • pdoError() public
    Convenience method to display a PDOException.
  • render() public
    Renders the response for the exception.

Method Detail

__construct() public ¶

__construct( Exception $exception )

Creates the controller to perform rendering on the error response. If the error is a CakeException 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

_cakeError() protected ¶

_cakeError( CakeException $error )

Generic handler for the internal framework errors CakePHP can generate.

Parameters
CakeException $error
The exception to render.

_getController() protected ¶

_getController( Exception $exception )

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

Parameters
Exception $exception
The exception to get a controller for.
Returns
Controller

_outputMessage() protected ¶

_outputMessage( string $template )

Generate the response using the controller object.

Parameters
string $template
The template to render.

_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

error400() public ¶

error400( Exception $error )

Convenience method to display a 400 series page.

Parameters
Exception $error
The exception to render.

error500() public ¶

error500( Exception $error )

Convenience method to display a 500 page.

Parameters
Exception $error
The exception to render.

pdoError() public ¶

pdoError( PDOException $error )

Convenience method to display a PDOException.

Parameters
PDOException $error
The exception to render.

render() public ¶

render( )

Renders the response for the exception.

Properties detail

$controller ¶

public Controller

Controller instance.

null

$error ¶

public Exception

The exception being handled.

null

$method ¶

public string

The method corresponding to the Exception this object is for.

''

$template ¶

public string

template to render for CakeException

''
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs