I was going through the list of predefined Exceptions in PHP and I noticed the DomainException. Anyone know what does DomainException mean? Does it mean failed data model valida
The description of RangeException is a bit more helpful:
Exception thrown to indicate range errors during program execution. Normally this means there was an arithmetic error other than under/overflow. This is the runtime version of DomainException.
I think it is applicable to non-arithmetic too, e.g. see this user comment.
For example, if you expect a value to be in the set {'jpeg', 'png', 'gif', 'bmp'}
and you receive something else like 'foo'
, it's a good candidate for a DomainException (logic) / RangeException (runtime). I'm pretty sure you could think of many other use cases.
Also, I just found this useful article, which provide more thorough explanations than php.net:
How to use built-in SPL exception classes for better error handling