8000 Custom exception handler in command · Issue #25769 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Custom exception handler in command #25769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fancyweb opened this issue Jan 11, 2018 · 2 comments
Closed

Custom exception handler in command #25769

fancyweb opened this issue Jan 11, 2018 · 2 comments

Comments

@fancyweb
Copy link
Contributor
Q A
Bug report? no
Feature request? no
BC Break report? yes
RFC? no
Symfony version 3.4

Hello, first of all excuse me if this is not a BC break or if my code is really bad but the exception / error handling is something I don't master at all.

So in one of my project command, I did this :

$this->getApplication()->setCatchExceptions(false);
$errorHandler = ErrorHandler::register(null, false);
$errorHandler->throwAt(E_ALL, true);
$errorHandler->setExceptionHandler(function () {
	// .... my code
});

to execute something whenever a Symfony command throws an exception or has any error.

In 3.3 and before, if this command throws an exception it goes in my custom exception handler. In 3.4 it doesn't.

@nicolas-grekas
Copy link
Member

Can you check if #25753 changes that?

@fancyweb
Copy link
Contributor Author

No it doesn't fix it.

If it can help, this is the output I get for :

        $this->getApplication()->setCatchExceptions(false);
        $errorHandler = ErrorHandler::register(null, false);
        $errorHandler->throwAt(E_ALL, true);
        $errorHandler->setExceptionHandler(function () {
            die('INSIDE MY CUSTOM EXCEPTION HANDLER');
        });

        throw new \Exception('MY EXCEPTION MESSAGE');

exc

The first run is 3.4, the second 3.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0