Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Exceptions in CakePHP

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 154
    Comment on it

    CakePHP uses the exceptions internally to show the logical cake PHP errors. All of the exceptions that occur in CakePHP raises a CakeException.

    CakePHP is also having the number of exception classes that we can use for HTTP errors.

    For congiguring exceptions in cakePHP we can use the code below

    Configure::write('Exception', array(
    'handler' => 'ErrorHandler::handleException',//The callback to handle exceptions. You can set this to any callback type,
    'renderer' => 'ExceptionRenderer',// The class responsible for rendering uncaught exceptions.
    'log' => true // boolean - When true, exceptions + their stack traces will be logged to CakeLog.
    ));
    

    If we changes the handler then this changing will allows us to take full control over the exception handling process. If we change the renderer , it allows us to change the output .

    Exception classes

    There are a number of exception classes in CakePHP. Each exception replaces a cakeError() error messages.

    There are several built-in exceptions inside CakePHP -->

    1-exception BadRequestException Used for doing 400 Bad Request error.

    2-exception UnauthorizedException Used for doing a 401 Unauthorized error.

    3-exception ForbiddenException Used for doing a 403 Forbidden error.

    4-exception NotFoundException Used for doing a 404 Not found error.

    5-exception MethodNotAllowedException Used for doing a 405 Method Not Allowed error.

    6-exception InternalErrorException Used for doing a 500 Internal Server Error.

    7-exception NotImplementedException Used for doing a 501 Not Implemented Errors.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: