Throwing an exception doesn't fire my custom error handler

I’ve setup a custom error handler controller. This prints out errors in JSON format.

I’ve created a custom Error Handler class like this

class ELanguageException extends CException implements ApiError  {

    public function __construct($message=null)


        if ($message==null) {






Whenever I have this code on other controller

throw new CHttpException(404, self::LANGUAGE_UNKNOWN);

my custom exception handler does fire, and I get the passed details.

But I have problem when I fire my custom error handler

throw new ELanguageException(self::LANGUAGE_UNKNOWN);

In this case, the Yii’s default error handler fires, and not my custom error handler. What I am doing wrong?

Can you include your source code for ApiError?

I just created the ELanguageException class, exactly as you’ve defined it (except for the “implements ApiError” part).

In my controller, I threw an exception, as shown, and the custom class ELanguageException handled the exception.

I don’t know what happens, but if I extend the class from [color=#1C2837][font=monospace][size=2][color=#660066]CHttpException[/color][color=#000000] [/color][/size][/font][/color]it does work. (The ApiError just holds some constants)