ApiException.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) 2011-2020, baomidou (jobob@qq.com).
  3. * <p>
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. * <p>
  8. * https://www.apache.org/licenses/LICENSE-2.0
  9. * <p>
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.baomidou.mybatisplus.extension.exceptions;
  17. import com.baomidou.mybatisplus.extension.api.IErrorCode;
  18. /**
  19. * REST API 请求异常类
  20. *
  21. * @author hubin
  22. * @since 2017-06-26
  23. */
  24. // 使用度较低,如果使用请及时迁移本地 3.5.0 移除
  25. @Deprecated
  26. public class ApiException extends RuntimeException {
  27. /**
  28. * serialVersionUID
  29. */
  30. private static final long serialVersionUID = -5885155226898287919L;
  31. /**
  32. * 错误码
  33. */
  34. private IErrorCode errorCode;
  35. public ApiException(IErrorCode errorCode) {
  36. super(errorCode.getMsg());
  37. this.errorCode = errorCode;
  38. }
  39. public ApiException(String message) {
  40. super(message);
  41. }
  42. public ApiException(Throwable cause) {
  43. super(cause);
  44. }
  45. public ApiException(String message, Throwable cause) {
  46. super(message, cause);
  47. }
  48. public IErrorCode getErrorCode() {
  49. return errorCode;
  50. }
  51. }