Re: [VOTE] Catching Multiple Exception Types

From: Date: Sat, 30 Apr 2016 10:17:52 +0000
Subject: Re: [VOTE] Catching Multiple Exception Types
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-92977@lists.php.net to get a copy of this message
Den 2016-04-25 kl. 11:49, skrev Rowan Collins:
Patrick ALLAERT wrote on 24/04/2016 14:18:
There is just nothing more repeatable or common cases than "resource not found", "method not allowed", "access denied",... They are all non exceptional cases better handled without exceptions and with clean APIs reflecting the business logic of the application.
I think part of the problem may be that non-trivial examples require rather a lot of context. An example that comes to my mind is if an application is combining a bunch of different libraries, and calling them all in sequence: try { $fooService->doStuff($data); $barService->doMoreStuff($data); $bazService->doDifferentStuff($data); } catch ( FooException | BarException | BazException $e ) { // We don't care which library threw the exception, the action is always the same throw new AppException($e); // Hide which libraries we're using to implement the function } Regards,
Good example, thats how I would use multi-catch. Regards //Björn Larsson

« previous php.internals (#92977) next »