content: /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package com.alipay.common.exception;
  
  
  import lombok.Data;
  import lombok.EqualsAndHashCode;
  import lombok.Getter;
  
  import java.io.Serial;
  
  /*
   *@title BizException
   *@description
   *@author jietian
   *@version 1.0
   *@create 2025/2/8 11:28
   */
  @EqualsAndHashCode(callSuper = true)
  @Data
  public class BizException extends RuntimeException {
      @Serial
      private static final long serialVersionUID = -7864604160297181941L;
  
      /**
       * 错误码
       * -- GETTER --
       * Getter method for property <tt>errorCode</tt>.
       */
      @Getter
      protected final ErrorCode errorCode;
  
      /**
       * 这个是和谐一些不必要的地方,冗余的字段
       * 尽量不要用
       */
      private String code;
  
      /**
       * 无参默认构造UNSPECIFIED
       */
      public BizException() {
          super(BizErrorCodeEnum.UNSPECIFIED.getDescription());
          this.errorCode = BizErrorCodeEnum.UNSPECIFIED;
      }
  
      /**
       * 指定错误码构造通用异常
       *
       * @param errorCode 错误码
       */
      public BizException(final ErrorCode errorCode) {
          super(errorCode.getDescription());
          this.errorCode = errorCode;
      }
  
      /**
       * 指定详细描述构造通用异常
       *
       * @param detailedMessage 详细描述
       */
      public BizException(final String detailedMessage) {
          super(detailedMessage);
          this.errorCode = BizErrorCodeEnum.UNSPECIFIED;
      }
  
      /**
       * 指定导火索构造通用异常
       *
       * @param t 导火索
       */
      public BizException(final Throwable t) {
          super(t);
          this.errorCode = BizErrorCodeEnum.UNSPECIFIED;
      }
  
      /**
       * 构造通用异常
       *
       * @param errorCode       错误码
       * @param detailedMessage 详细描述
       */
      public BizException(final ErrorCode errorCode, final String detailedMessage) {
          super(detailedMessage);
          this.errorCode = errorCode;
      }
  
      /**
       * 构造通用异常
       *
       * @param errorCode 错误码
       * @param t         导火索
       */
      public BizException(final ErrorCode errorCode, final Throwable t) {
          super(errorCode.getDescription(), t);
          this.errorCode = errorCode;
      }
  
      /**
       * 构造通用异常
       *
       * @param detailedMessage 详细描述
       * @param t               导火索
       */
      public BizException(final String detailedMessage, final Throwable t) {
          super(detailedMessage, t);
          this.errorCode = BizErrorCodeEnum.UNSPECIFIED;
      }
  
      /**
       * 构造通用异常
       *
       * @param errorCode       错误码
       * @param detailedMessage 详细描述
       * @param t               导火索
       */
      public BizException(final ErrorCode errorCode, final String detailedMessage,
                          final Throwable t) {
          super(detailedMessage, t);
          this.errorCode = errorCode;
      }
  
  }
  