content: /*
   * 爱组搭，低代码组件化开发平台
   * ------------------------------------------
   * 受知识产权保护，请勿删除版权申明，开发平台不允许做非法网站，后果自负
   */
  package com.aizuda.core.exception;
  
  import com.aizuda.core.api.IErrorCode;
  import lombok.Getter;
  import lombok.extern.slf4j.Slf4j;
  
  import java.io.PrintWriter;
  import java.io.StringWriter;
  
  /**
   * <a href="http://aizuda.com">爱组搭</a>低代码组件化开发平台
   * ----------------------------------------
   * REST API 请求异常类
   *
   * @author 青苗
   * @since 1.1.0
   */
  @Slf4j
  public class ApiException extends RuntimeException {
      /**
       * serialVersionUID
       */
      private static final long serialVersionUID = -5885155226898287919L;
      /**
       * 错误码
       */
      @Getter
      private long code;
  
      public ApiException(long code, String message) {
          super(message);
          this.code = code;
      }
  
      public ApiException(IErrorCode errorCode) {
          super(errorCode.getMsg());
          this.code = errorCode.getCode();
      }
  
      public ApiException(String message) {
          super(message);
      }
  
      public ApiException(Throwable cause) {
          super(cause);
      }
  
      public ApiException(String message, Throwable cause) {
          super(message, cause);
      }
  
      public static String getStackTraceAsString(Throwable throwable) {
          StringWriter stringWriter = new StringWriter();
          throwable.printStackTrace(new PrintWriter(stringWriter));
          return stringWriter.toString();
      }
  }
  