Skip to content
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

New extender for error handling #1970

Merged
merged 1 commit into from Jan 31, 2020
Merged

Conversation

@franzliedke
Copy link
Member

franzliedke commented Jan 17, 2020

Fixes #1781

This extender implements several methods for extending the new error
handling stack implemented in #1843.

Most use-cases should be covered, but I expect some challenges for more
complex setups. We can tackle those once they come up, though. Basic
use-cases should be covered.

Confirmed

  • Tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
@franzliedke

This comment has been minimized.

Copy link
Member Author

franzliedke commented Jan 17, 2020

Tagging some people:

@matteocontrini

This comment has been minimized.

Copy link
Contributor

matteocontrini commented Jan 17, 2020

So taking in consideration the use case mentioned in the issue the usage of this extender would be something like:

return [
    (new Extend\ErrorHandling)
        ->handler(MyException::class, MyExceptionHandler::class)
];

Where MyExceptionHandler exposes an handle method. Is that correct?

Shouldn't there be an interface for exception handlers, perhaps?

@franzliedke

This comment has been minimized.

Copy link
Member Author

franzliedke commented Jan 17, 2020

@matteocontrini That depends on the exact use-case. If all you're doing is configuring the status code for an exception, you should use the other methods.

Handlers are really only necessary for adding more details to error output (in the JSON-API layer). #1843 removed most of our layers, and only two remain - those embed validation errors into the JSON-API response. So, assuming you're doing something simpler than that, please try out the other methods.

Shouldn't there be an interface for exception handlers, perhaps?

I thought about it and it does not help much, as that would mean you cannot type hint the argument to the handle() class.

Copy link
Member

datitisev left a comment

PHPDoc needed for handler method - probably including warning that one of the other methods should work instead or something. And perhaps specify what instances it would be used and why the others don't help in those... if that makes sense.

This extender implements several methods for extending the new error
handling stack implemented in #1843.

Most use-cases should be covered, but I expect some challenges for more
complex setups. We can tackle those once they come up, though. Basic
use-cases should be covered.

Fixes #1781.
@franzliedke franzliedke force-pushed the fl/1781-extender-errorhandling branch from 8f0d739 to 02249fe Jan 18, 2020
@franzliedke

This comment has been minimized.

Copy link
Member Author

franzliedke commented Jan 18, 2020

You're right, thanks! Added another docblock.

@franzliedke franzliedke requested a review from datitisev Jan 18, 2020
Copy link
Member

datitisev left a comment

LGTM!

@franzliedke franzliedke merged commit dce36cb into master Jan 31, 2020
19 checks passed
19 checks passed
PHP 7.1 / MySQL
Details
PHP 7.1 / MySQL
Details
PHP 7.1 / MariaDB
Details
PHP 7.1 / MariaDB
Details
PHP 7.2 / MySQL
Details
PHP 7.2 / MySQL
Details
PHP 7.2 / MariaDB
Details
PHP 7.2 / MariaDB
Details
PHP 7.3 / MySQL
Details
PHP 7.3 / MySQL
Details
PHP 7.3 / MySQL (prefix)
Details
PHP 7.3 / MySQL (prefix)
Details
PHP 7.3 / MariaDB
Details
PHP 7.3 / MariaDB
Details
PHP 7.3 / MariaDB (prefix)
Details
PHP 7.3 / MariaDB (prefix)
Details
WIP Ready for review
Details
continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/styleci/push The analysis has passed
Details
@franzliedke franzliedke deleted the fl/1781-extender-errorhandling branch Jan 31, 2020
luceos added a commit that referenced this pull request Feb 4, 2020
This extender implements several methods for extending the new error
handling stack implemented in #1843.

Most use-cases should be covered, but I expect some challenges for more
complex setups. We can tackle those once they come up, though. Basic
use-cases should be covered.

Fixes #1781.
wzdiyb added a commit to wzdiyb/core that referenced this pull request Feb 16, 2020
This extender implements several methods for extending the new error
handling stack implemented in flarum#1843.

Most use-cases should be covered, but I expect some challenges for more
complex setups. We can tackle those once they come up, though. Basic
use-cases should be covered.

Fixes flarum#1781.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.