ghislainf / zf2-whoops

PHP whoops error on ZF2 framework
https://github.com/filp/whoops
58 stars 10 forks source link

checked exception #1

Closed stefanorg closed 11 years ago

stefanorg commented 11 years ago

Hi, how to handle checked exception, like BjyAuthorize\Exception\UnAuthorizedException?

stefanorg commented 11 years ago

@ghislainf up

ghislainf commented 11 years ago

Can you be more specific ?

stefanorg commented 11 years ago

Yes, in a SkeletonApplication require: "bjyoungblood/bjy-authorize" following the instructions: https://github.com/bjyoungblood/BjyAuthorize

Once enable, BjyAuthorize if you try to visit a resource without a permission (for example the home page for which you need the role 'user') it raise the: UnAuthorizedException (BjyAuthorize\Exception\UnAuthorizedException) and by default it will display the Unauthorized message (403 error page) With whoops enabled in application.config.php it's impossible to see the 403 error message because whoops catch the exception and it shows the PrettyPageHandler error page.

ghislainf commented 11 years ago

Sorry for my long response time... The exception message of BjyAuthorize\Exception\UnAuthorizedException are currently show in PrettyPageHandler.

In fact, BjyAuthorize\Exception\UnAuthorizedException extends \BadMethodCallException When you throw a \BadMethodCallException exception with a message, it's visible on whoops prettypage.

throw new \BadMethodCallException('hello');

whoops

stefanorg commented 11 years ago

Hi @ghislainf , thanks for your response. The point is that when the application rise the BjyAuthorize\Exception\UnAuthorizedException i DON'T want to see the PrettyPageHandler page, but i want to see the default login page or the "friendly" message to the user "You are not authorized ..."

Practically speaking, i want to tell zfwhoops: "when you see 'BjyAuthorize\Exception\UnAuthorizedException' don't catch him and let zf2 handle that, because that exception is known to me and i throw it voluntarily"

hope you got the point.

ps: sorry for my english

ghislainf commented 11 years ago

Ok @stefanorg.

Now you can define the specfics exceptions which should not be catch by whoops.

return array(
    'view_manager' => array(
        'whoops_no_catch' => array(
            'BjyAuthorize\Exception\UnAuthorizedException',
            'AnotherException',
            ...
        )
    )
);