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
Improve try catch middleware #23
Conversation
043a99e
to
7c638bb
Compare
@f3l1x I am thinking about little bit more complicated configuration. We have two options in Apitte for catching exceptions - catchExceptions and debug. Similar way is also used in nette/application https://github.com/nette/application/blob/master/src/Application/Application.php#L87-L91 |
src/TryCatchMiddleware.php
Outdated
/** @var LoggerInterface|null */ | ||
private $logger; | ||
|
||
public function __construct(?LoggerInterface $logger = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, but I would prefer set optionall dependencies via setter. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right.
src/TryCatchMiddleware.php
Outdated
@@ -33,4 +43,11 @@ public function setCatchExceptions(bool $catch): void | |||
$this->catch = $catch; | |||
} | |||
|
|||
private function logError(Throwable $throwable): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole middleware is about error/exceptions, so we can rename it to just log() function. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
7c638bb
to
4bc6ac5
Compare
4bc6ac5
to
a896203
Compare
Closes #20