Thank you, I got it figured out. I have not personally worked with implementing interfaces before, had seen classes that implemented them but wasn't aware they could both extend another class *and* implement an interface. So it was ignorance confusing me. I have it working now extending \InvalidArgumentException which from the name of the interface is what I'm guessing was intended, which lets me catch them with \InvalidArgumentException which I'm guessing is also what was intended.
On Monday, February 26, 2018 at 3:35:15 AM UTC-8, Paul Dragoonis wrote: > > Hi Alice, > > It's recommended not to throw \Exception but throw your own cache > exception class, which implement's PSR-16's CacheException. > > """ > use Psr\SimpleCache\CacheException; > class MyProjectsCacheException extends Exception implements CacheException > """ > > This way you'll be able to continue to catch(Exception $e) in general, but > also be specific and typehint on CacheException if you need to. > > I hope that answers your question. > > Many thanks, > Paul > > > On Sat, Feb 24, 2018 at 8:02 PM, Chuck Burgess <[email protected] > <javascript:>> wrote: > >> Purpose of the interfaces is to make those exact exception types >> *catchable*... that's all. >> >> On Feb 24, 2018 13:56, "Alice Wonder" <[email protected] <javascript:>> >> wrote: >> >>> I have a personal cache class that would be cake to port to use PSR-16, >>> but PSR-16 also defines two exception interfaces. >>> >>> Is it really necessary I extend those two interfaces rather than extend >>> a different exception interface? >>> >>> zetacomponents base package has an abstract exceptions class I sometimes >>> extend. >>> >>> If I have to implement the interface in PSR-16 to be compliant than to >>> use that abstract class I would have to change that abstract class to >>> implement the PSR-16 exception interfaces instead of just \Exception and it >>> strikes me that that is just, well, absurd since the PSR-16 interfaces >>> don't do anything or even extend \Exception. >>> >>> Am I not understanding the purpose of those interfaces? >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "PHP Framework Interoperability Group" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected] <javascript:>. >>> To post to this group, send email to [email protected] >>> <javascript:>. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/php-fig/85594732-4a0a-4058-a263-a48db4738e70%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/php-fig/85594732-4a0a-4058-a263-a48db4738e70%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "PHP Framework Interoperability Group" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/php-fig/CANsgjns%3DWYjjQ43OC0RMkgLSRBUAmrjKGcaPbhU8cyVsgf3HpA%40mail.gmail.com >> >> <https://groups.google.com/d/msgid/php-fig/CANsgjns%3DWYjjQ43OC0RMkgLSRBUAmrjKGcaPbhU8cyVsgf3HpA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/2a369451-f576-4e60-9b33-15085c257cb6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
