Exception.php 847 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Yansongda\Pay\Exceptions;
  3. class Exception extends \Exception
  4. {
  5. const UNKNOWN_ERROR = 9999;
  6. const INVALID_GATEWAY = 1;
  7. const INVALID_CONFIG = 2;
  8. const INVALID_ARGUMENT = 3;
  9. const ERROR_GATEWAY = 4;
  10. const INVALID_SIGN = 5;
  11. const ERROR_BUSINESS = 6;
  12. /**
  13. * Raw error info.
  14. *
  15. * @var array
  16. */
  17. public $raw;
  18. /**
  19. * Bootstrap.
  20. *
  21. * @author yansongda <me@yansonga.cn>
  22. *
  23. * @param string $message
  24. * @param array|string $raw
  25. * @param int|string $code
  26. */
  27. public function __construct($message = '', $raw = [], $code = self::UNKNOWN_ERROR)
  28. {
  29. $message = '' === $message ? 'Unknown Error' : $message;
  30. $this->raw = is_array($raw) ? $raw : [$raw];
  31. parent::__construct($message, intval($code));
  32. }
  33. }