views:

149

answers:

1

I am implementing a web service as part of an app I am building and would like all errors returned in XML when the initial request is XML

I found this article:

http://www.cake-toppings.com/2009/03/31/displaying-custom-error-message-with-the-right-http-response-codes/

And while I have it working if I manually fire the error, I want to be able to catch missing method errors etc...

Any advice?

+1  A: 

You can override those method of the ErrorHandler class http://api.cakephp.org/class/error-handler

Ex: Missing Controller. Override this method inside your app/app_error.php

class AppError extends ErrorHandler {
    function missingController($params) {
            pr($params);

            /*
            [className] => BadController
            [webroot] => /web/www
            [url] => bad
            [base] => /web/www/index.php
            */        
        }
}

So inside this method, you can have your own custom logic to send xml with error codes.

KienPham.com
Perfect thanks!
unidev