chargebee / chargebee-java

Java library for the Chargebee API.

Home Page:https://apidocs.chargebee.com/docs/api?lang=java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

APIException constructor should not `throw Exception`

janv opened this issue · comments

Dealing with the Chargebee API Excpetions is quite painful. Even though they are descendants of the RuntimeException and should not need to be checked, their constructor has a throws Exception annotation, defeating the purpose!

public APIException(int httpStatusCode,JSONObject jsonObj) throws Exception {
super(jsonObj.getString("message"));
this.jsonObj = jsonObj;
this.httpStatusCode = httpStatusCode;
this.apiErrorCode = jsonObj.getString("api_error_code");
this.type = jsonObj.optString("type");
this.param = jsonObj.optString("param");
this.httpCode = httpStatusCode;
this.code = jsonObj.getString("error_code");
this.message = jsonObj.getString("error_msg");
}

Could you please remove that throws Exception declaration?

And consequently also remove all the other unnecessary throws Exception declarations from your request methods?

This has been fixed since v2.7.8