Re: [PHP-DEV] Using less generic exceptions for dates

2022-11-30 Thread Derick Rethans
On Mon, 21 Nov 2022, Derick Rethans wrote: > On 21 November 2022 11:34:10 GMT, Vincent Langlet > wrote: > > > >When using json_encode or json_decode with the `JSON_THROW_ON_ERROR` > >flag, `JsonException` might be thrown. > > > >When using `new DateTime('foo')`, a generic `Exception` is

Re: [PHP-DEV] Using less generic exceptions for dates

2022-11-22 Thread Tim Düsterhus
Hi On 11/21/22 13:36, Derick Rethans wrote: But my main point is that I think it would be useful to use a specific exception ``` class DateException extends Exception {} ``` - It allows a specific treatment when catching exceptions - It allows a specific analysis when using static analysis

Re: [PHP-DEV] Using less generic exceptions for dates

2022-11-21 Thread Derick Rethans
On 21 November 2022 11:34:10 GMT, Vincent Langlet wrote: >Hi, > >When using json_encode or json_decode with the `JSON_THROW_ON_ERROR` flag, >`JsonException` might be thrown. > >When using `new DateTime('foo')`, a generic `Exception` is thrown. >Incidentally, I wonder why it's not an

[PHP-DEV] Using less generic exceptions for dates

2022-11-21 Thread Vincent Langlet
Hi, When using json_encode or json_decode with the `JSON_THROW_ON_ERROR` flag, `JsonException` might be thrown. When using `new DateTime('foo')`, a generic `Exception` is thrown. Incidentally, I wonder why it's not an `InvalidArgumentException` (but that could be another debate). But my main