OAuthException.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace crmeb\services\oauth;
  12. /**
  13. * Class OAuthException
  14. * @package crmeb\services\oauth
  15. */
  16. class OAuthException extends \RuntimeException
  17. {
  18. /**
  19. * OAuthException constructor.
  20. * @param $message
  21. * @param array $replace
  22. * @param int $code
  23. * @param \Throwable|null $previous
  24. */
  25. public function __construct($message, $replace = [], $code = 0, \Throwable $previous = null)
  26. {
  27. if (is_array($message)) {
  28. $errInfo = $message;
  29. $message = $errInfo[1] ?? '未知错误';
  30. if ($code === 0) {
  31. $code = $errInfo[0] ?? 400;
  32. }
  33. }
  34. if (is_numeric($message)) {
  35. $code = $message;
  36. $message = getLang($message, $replace);
  37. }
  38. parent::__construct($message, $code, $previous);
  39. }
  40. }