One exasan or many?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
14 views
What variant is more correct
try { ... } catch (Throwable $throwable) { $this->logger->error( $throwable->getMessage() ); }

or
try { ... } catch (Exception1 | Exception2 | Exception3 | Exception4 | Exception5 | Exception6 | Exception7 $throwable) { $this->logger->error( $throwable->getMessage() ); }


Which approach is more correct? Why?
by | 14 views

1 Answer

0 like 0 dislike
To start, you need to understand that try/catch - it's not about mistakes, it's about control flows.
You have the main flow of control - one that you build out any IFS ever existed, for s, function calls and returns from them in General of normal operators.
But there is an alternative flow, which allows under certain conditions (namely when an exception is thrown) transferred to another point of the program, with another state of the call stack that it'd actually be possible to do the usual operators, but required a lot of scribbling.
Be transported to another point of the program may need to reboot it, staying in a correct and understandable program status.
To shit in the log, do not have anywhere to move - exception logging subsystem do not usually break.
Until enough.
by

Related questions

0 like 0 dislike
4 answers
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
35,593 users