0

For exception handling I plan to use this approach

1) Can you mention about the differences between them? Cookbook tells the difference with this sentence

"If you don’t want to take control of the exception handling, but want to change how exceptions are rendered..."

2) I'm planning to add 503 Service Unavailable code as an exception. But How can I implement this error?
Cookbook has such an example for missingWidget, how can I change it for 503 service not available?

class AppExceptionRenderer extends ExceptionRenderer {
    public function missingWidget($error) {
        echo 'Oops that widget is missing!';
    }
}
trante
  • 33,518
  • 47
  • 192
  • 272

1 Answers1

2

You can use InternalErrorException already available in core.

throw new InternalErrorException('Service Unavailable', 503)

The error page will be rendered by ExceptionRenderer::error500() method using the view app/View/Errors/error500.ctp. Depending on your needs you can either customize just the view file or make your custom exception renderer which extends ExceptionRenderer and override the error500() method.

ADmad
  • 8,102
  • 16
  • 18
  • Can you please mention about the two approaches "Create your own Exception handler with Exception.handler" and "Using a custom renderer with Exception.renderer to handle application exceptions" ?? I'm trying to make a decision to use which one of them. Thank you – trante Aug 23 '12 at 09:16