When would you throw a DomainException in PHP?

前端 未结 3 615
攒了一身酷
攒了一身酷 2021-02-07 01:13

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

3条回答
  •  醉梦人生
    2021-02-07 01:43

    This kind of exception should be used to inform about domain errors in mathematical sense.

    See domain of a function.

    For example, the square root function will only be defined for positive numbers (unless you're using complex numbers...)

提交回复
热议问题