com.antonioaltieri.telegram.botapi.requests.ApiException Maven / Gradle / Ivy
package com.antonioaltieri.telegram.botapi.requests;
import com.antonioaltieri.telegram.botapi.requests.ApiResult;
public class ApiException extends RuntimeException {
private String methodName;
public ApiException(String methodName) {
super(String.format("An exception occurred while accessing %s.", methodName));
this.methodName = methodName;
}
public ApiException(String methodName, Throwable cause) {
super(String.format("An exception occurred while accessing %s.", methodName), cause);
this.methodName = methodName;
}
public ApiException(String methodName, ApiResult> unexpectedResult) {
super(String.format("Unexpected result received from Telegram while accessing %s: %s.", methodName, unexpectedResult));
this.methodName = methodName;
}
public String getMethodName() {
return methodName;
}
@Override
public String toString() {
if (getCause() == null)
return super.toString();
else
return super.toString() + " Caused by: " + getCause().toString();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy