ErrorCodeConstants.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Bear
  5. * Date: 2018/11/29
  6. * Time: 上午11:00
  7. */
  8. namespace app\main\constants;
  9. class ErrorCodeConstants
  10. {
  11. const SUCCESS = 0;
  12. const PARAMS_ERROR_EMPTY = 1;//参数为空
  13. const PARAMS_ERROR_TYPE = 2;//参数数据类型错误
  14. const PARAMS_ERROR_INVALID = 3;//参数无效
  15. const DB_ERROR_UPDATE = 4;//更新错误
  16. const DB_ERROR_SELECT = 5;//查询无结果
  17. const DB_ERROR_TIMEOUT = 6;//查询超时
  18. const API_ERROR = 7;//调用api返回错误
  19. const EXCEPTION = 8;//程序异常
  20. const PERMISSION_DENY = 9;//权限不足
  21. const REDIRECT = 10;//重定向
  22. const REDIRECT_VIEW = 11;//返回渲染页面
  23. const RESULT_EMPTY = 12;//未查询到结果
  24. const VISIT_EXCEED = 13;//访问次数超过限制
  25. public static $normalCodes = [
  26. self::SUCCESS,
  27. self::REDIRECT,
  28. self::REDIRECT_VIEW,
  29. self::RESULT_EMPTY,
  30. self::VISIT_EXCEED,
  31. ];
  32. /**
  33. * 检查错误码是否记录日志
  34. * @param $code
  35. * @return bool
  36. */
  37. public static function checkErrorCodeToLog($code)
  38. {
  39. return !in_array($code, self::$normalCodes);
  40. }
  41. }