CrudException.php 1.2 KB

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