Fix responseerror
This commit is contained in:
parent
85594c61ea
commit
d832f1d55c
@ -17,59 +17,69 @@ public class ResponseError extends IOException {
|
|||||||
private final int code;
|
private final int code;
|
||||||
@NotNull
|
@NotNull
|
||||||
private final String message;
|
private final String message;
|
||||||
private final Throwable cause;
|
|
||||||
|
|
||||||
public ResponseError(@NotNull Function function, @NotNull String botName, @NotNull TdApi.Error cause) {
|
private ResponseError(@NotNull Function function, @NotNull String botName, @NotNull TdApi.Error tdError, @Nullable Throwable cause) {
|
||||||
super("Bot '" + botName + "' failed the request '" + functionToInlineString(function) + "': " + cause.code + " " + cause.message);
|
super("Bot '" + botName + "' failed the request '" + functionToInlineString(function) + "': " + tdError.code + " " + tdError.message, cause);
|
||||||
this.botName = botName;
|
this.botName = botName;
|
||||||
this.tag = functionToInlineString(function);
|
this.tag = functionToInlineString(function);
|
||||||
this.code = cause.code;
|
this.code = tdError.code;
|
||||||
this.message = cause.message;
|
this.message = tdError.message;
|
||||||
this.cause = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseError(@NotNull String tag, @NotNull String botName, @NotNull TdApi.Error cause) {
|
private ResponseError(@NotNull String tag, @NotNull String botName, @NotNull TdApi.Error tdError, @Nullable Throwable cause) {
|
||||||
super("Bot '" + botName + "' failed the request '" + tag + "': " + cause.code + " " + cause.message);
|
super("Bot '" + botName + "' failed the request '" + tag + "': " + tdError.code + " " + tdError.message, cause);
|
||||||
this.botName = botName;
|
this.botName = botName;
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.code = cause.code;
|
this.code = tdError.code;
|
||||||
this.message = cause.message;
|
this.message = tdError.message;
|
||||||
this.cause = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseError(@NotNull Function function, @NotNull String botName, @NotNull Throwable cause) {
|
private ResponseError(@NotNull Function function, @NotNull String botName, @Nullable Throwable cause) {
|
||||||
super("Bot '" + botName + "' failed the request '" + functionToInlineString(function) + "': " + cause.getMessage());
|
super("Bot '" + botName + "' failed the request '" + functionToInlineString(function) + "': " + (cause == null ? null : cause.getMessage()), cause);
|
||||||
this.botName = botName;
|
this.botName = botName;
|
||||||
this.tag = functionToInlineString(function);
|
this.tag = functionToInlineString(function);
|
||||||
this.code = 500;
|
this.code = 500;
|
||||||
this.message = cause.getMessage();
|
this.message = (cause == null ? "" : (cause.getMessage() == null ? "" : cause.getMessage()));
|
||||||
this.cause = cause;
|
|
||||||
this.initCause(cause);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseError(@NotNull String tag, @NotNull String botName, @NotNull Throwable cause) {
|
private ResponseError(@NotNull String tag, @NotNull String botName, @Nullable Throwable cause) {
|
||||||
super("Bot '" + botName + "' failed the request '" + tag + "': " + cause.getMessage());
|
super("Bot '" + botName + "' failed the request '" + tag + "': " + (cause == null ? null : cause.getMessage()), cause);
|
||||||
this.botName = botName;
|
this.botName = botName;
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.code = 500;
|
this.code = 500;
|
||||||
this.message = cause.getMessage();
|
this.message = (cause == null ? "" : (cause.getMessage() == null ? "" : cause.getMessage()));
|
||||||
this.cause = cause;
|
|
||||||
this.initCause(cause);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResponseError newResponseError(@NotNull Function function, @NotNull String botName, @NotNull TdApi.Error cause) {
|
public static ResponseError newResponseError(@NotNull Function function,
|
||||||
|
@NotNull String botName,
|
||||||
|
@NotNull TdApi.Error tdError,
|
||||||
|
@Nullable Throwable cause) {
|
||||||
|
return new ResponseError(function, botName, tdError, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseError newResponseError(@NotNull String tag,
|
||||||
|
@NotNull String botName,
|
||||||
|
@NotNull TdApi.Error tdError,
|
||||||
|
@Nullable Throwable cause) {
|
||||||
|
return new ResponseError(tag, botName, tdError, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseError newResponseError(@NotNull String tag,
|
||||||
|
@NotNull String botName,
|
||||||
|
@NotNull TdApi.Error tdError,
|
||||||
|
@Nullable TdError cause) {
|
||||||
|
return new ResponseError(tag, botName, tdError, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseError newResponseError(@NotNull Function function,
|
||||||
|
@NotNull String botName,
|
||||||
|
@Nullable Throwable cause) {
|
||||||
return new ResponseError(function, botName, cause);
|
return new ResponseError(function, botName, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResponseError newResponseError(@NotNull String tag, @NotNull String botName, @NotNull TdApi.Error cause) {
|
public static ResponseError newResponseError(@NotNull String tag,
|
||||||
return new ResponseError(tag, botName, cause);
|
@NotNull String botName,
|
||||||
}
|
@Nullable Throwable cause) {
|
||||||
|
|
||||||
public static ResponseError newResponseError(@NotNull Function function, @NotNull String botName, @NotNull Throwable cause) {
|
|
||||||
return new ResponseError(function, botName, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResponseError newResponseError(@NotNull String tag, @NotNull String botName, @NotNull Throwable cause) {
|
|
||||||
return new ResponseError(tag, botName, cause);
|
return new ResponseError(tag, botName, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user