Exception.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. declare(strict_types=1);
  3. namespace Yansongda\Artful\Exception;
  4. use Throwable;
  5. class Exception extends \Exception
  6. {
  7. public const UNKNOWN_ERROR = 9999;
  8. /**
  9. * 关于容器.
  10. */
  11. public const CONTAINER_ERROR = 9100;
  12. public const CONTAINER_NOT_FOUND = 9101;
  13. public const CONTAINER_SERVICE_NOT_FOUND = 9102;
  14. /**
  15. * 关于参数.
  16. */
  17. public const PARAMS_ERROR = 9200;
  18. public const PARAMS_DIRECTION_INVALID = 9201;
  19. public const PARAMS_PACKER_INVALID = 9202;
  20. public const PARAMS_EVENT_DRIVER_INVALID = 9203;
  21. public const PARAMS_HTTP_CLIENT_INVALID = 9204;
  22. public const PARAMS_LOGGER_DRIVER_INVALID = 9205;
  23. public const PARAMS_HTTP_CLIENT_FACTORY_INVALID = 9206;
  24. public const PARAMS_PLUGIN_INCOMPATIBLE = 9207;
  25. public const PARAMS_PARSER_DIRECTION_INVALID = 9208;
  26. public const PARAMS_SHORTCUT_INVALID = 9209;
  27. /**
  28. * 关于响应.
  29. */
  30. public const RESPONSE_ERROR = 9300;
  31. public const REQUEST_RESPONSE_ERROR = 9301;
  32. public const RESPONSE_UNPACK_ERROR = 9302;
  33. public const RESPONSE_EMPTY = 9303;
  34. /**
  35. * 关于配置.
  36. */
  37. public const CONFIG_ERROR = 9400;
  38. public mixed $extra;
  39. public function __construct(string $message = '未知异常', int $code = self::UNKNOWN_ERROR, mixed $extra = null, ?Throwable $previous = null)
  40. {
  41. $this->extra = $extra;
  42. parent::__construct($message, $code, $previous);
  43. }
  44. }