Disable stacktrace in validation exception

This commit is contained in:
Andrea Cavalli 2022-01-29 12:29:58 +01:00
parent b1b191a6e7
commit d6f1aa70db

View File

@ -26,24 +26,28 @@ import org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod;
* Exception from method validations
*/
public class TelegramApiValidationException extends TelegramApiException {
private PartialBotApiMethod method;
public static final StackTraceElement[] EMPTY_STACK_TRACE = new StackTraceElement[0];
private PartialBotApiMethod<?> method;
private BotApiObject object;
public TelegramApiValidationException(String message, PartialBotApiMethod method) {
public TelegramApiValidationException(String message, PartialBotApiMethod<?> method) {
super(message);
this.method = method;
this.setStackTrace(new StackTraceElement[0]);
}
public TelegramApiValidationException(String message, BotApiObject object) {
super(message);
this.object = object;
this.setStackTrace(EMPTY_STACK_TRACE);
}
public BotApiObject getObject() {
return object;
}
public PartialBotApiMethod getMethod() {
public PartialBotApiMethod<?> getMethod() {
return method;
}
@ -57,4 +61,9 @@ public class TelegramApiValidationException extends TelegramApiException {
}
return super.toString();
}
@Override
public Throwable fillInStackTrace() {
return this;
}
}