Uh oh!
There was an error while loading. Please reload this page.
feat: custom exception handler - #6710
Conversation
MGatner
left a comment
There was a problem hiding this comment.
This is a big one, I will have to come back to it! Initially it looks really good. Please be sure to work with @lonnieezell for feature consistency and @paulbalandan if there's any collaboration to be had with the deprecations handler PR.
Uh oh!
There was an error while loading. Please reload this page.
lonnieezell
commented
Oct 18, 2022
I'll be honest - this week I'm completely wrecked for time so I won't be able to really review until next week. That said - the reason nothing happened with the original one was because it was a BC break and would have to wait until v5. Has the BC break portion been fixed with this PR? |
kenjis
commented
Oct 18, 2022
No problem. The original PR was created many months ago. I have tried to keep this PR free of BC breaks. |
b22c181 to
2017313Comparekenjis
commented
Oct 23, 2022
Rebased. |
af3f99e to
9db24aaCompare
MGatner
left a comment
There was a problem hiding this comment.
I haven't looked at docs and tests yet, but this is looking great! I added some comments but two broad thoughts:
- It seems like the new classes are independent of the existing ones, and you use the current handle as a mediator to call them when available. I like the freedom that gives us - but then you kept ExceptionHandler compatible with the current class. It don't understand the need for this backwards-compatibility, unless I am missing something?
- I know we've been burned by class-interface-abstraction, but enforcing our BaseExceptionHandler for a single
handle()method feels unduly restrictive. I would like to see an interface (just that method) used as the return from the Config file and the abstract class becomes optional.
Uh oh!
There was an error while loading. Please reload this page.
| * | ||
| * @return bool|string | ||
| */ | ||
| protected static function highlightFile(string $file, int $lineNumber, int $lines = 15) |
There was a problem hiding this comment.
Since the existing handler doesn't actually extend this base, can we go ahead and type this?
| // For upgraded users. | ||
| if (! method_exists($this->config, 'handler')) { | ||
| $this->defaultExceptionHandler($exception, $statusCode, $exitCode); |
There was a problem hiding this comment.
Why doesn't this use ExceptionHandler? Is it not backwards-compatible behavior?
There was a problem hiding this comment.
Good point.
It should use ExceptionHandler.
When using ExceptionHandler, if the behavior changes it is a breaking change.
Uh oh!
There was an error while loading. Please reload this page.
| /** | ||
| * Determines the correct way to display the error. | ||
| * | ||
| * @return void |
There was a problem hiding this comment.
It feels like a big loss not having this in the abstraction. Any reason not to do that?
9db24aa to
b93407cCompareThe section "Error Handling" has been added.
b93407c to
9d5d44fComparekenjis
commented
Oct 27, 2022
No. If a dev overrides the following methods, this PR breaks the extended Exceptions:
|
kenjis
commented
Oct 27, 2022
Reverting 9d5d44f and a dev does not update the Config class, |
MGatner
commented
Oct 27, 2022
I'm confused; I think I missed something. |
MGatner
commented
Oct 27, 2022
If we want to support extended classes just check |
kenjis
commented
Oct 27, 2022
The new classes do not need to be backwards-compatible with Exceptions. A dev can replace Exceptions with their custom extended class now, and if the dev overrides one of some methods,
It may be Okay with that check, as a dev would not need to use their own ExceptionHandler and replace Exceptions at the same time. |
lonnieezell
left a comment
There was a problem hiding this comment.
Looks pretty good to me. I just found one edge case that we don't handle.
| $viewFile = null; | ||
| if (is_file($path . $view)) { | ||
| $viewFile = $path . $view; | ||
| } elseif (is_file($altPath . $altView)) { |
There was a problem hiding this comment.
Seems like we need to handle if neither file exists?
MGatner
commented
Oct 28, 2022
Since this is the case please add explicit types to all the new class methods. I am also still keen on adding an interface - nothing else in the base class is mandatory so we shouldn't restrict users to extending it. |
Description
Supersedes #5675
Checklist: