All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.qcloud.cos.exception.AbstractCosException Maven / Gradle / Ivy

There is a newer version: 5.6.238.2
Show newest version
package com.qcloud.cos.exception;

import org.json.JSONObject;

import com.qcloud.cos.http.ResponseBodyKey;

/**
 * 封装cos异常
 * @author chengwu
 *
 */
public abstract class AbstractCosException extends Exception {

    private static final long serialVersionUID = 7547532865194837136L;
    
    private CosExceptionType type;

    public AbstractCosException(CosExceptionType type, String message) {
        super(message);
        this.type = type;
    }

    public CosExceptionType getType() {
        return type;
    }
    
    @Override
    public String toString() {
        JSONObject responseObj = new JSONObject();
        responseObj.put(ResponseBodyKey.CODE, type.getErrorCode());
        responseObj.put(ResponseBodyKey.MESSAGE, getMessage());
        return responseObj.toString();
    }
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy