What values I can use for the $code property of a custom PHP exception

Viewed 26

The PHP exception documentation found on the official PHP website states that the default value for the $code property of the Exception class, if not provided explicitly, is 0:

public __construct(string $message = "", int $code = 0, ?Throwable $previous = null)

So whenever I implement a custom Exception, I can specify a custom exception code by passing it to the parent::__construct() call.

However, I haven't found any information regarding what codes, if any, are reserved for the standard PHP exceptions, like the RuntimeException. Do they all set this property to 0 and I can put whatever value I want in my custom exceptions?

0 Answers
Related