Implement "TooManyRequests" error
This commit is contained in:
parent
6f904af461
commit
45c1bdc37b
@ -1,6 +1,7 @@
|
|||||||
package org.telegram.telegrambots.updatesreceivers;
|
package org.telegram.telegrambots.updatesreceivers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import javax.ws.rs.core.Response.Status;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.telegram.telegrambots.Constants;
|
import org.telegram.telegrambots.Constants;
|
||||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||||
@ -49,6 +50,8 @@ public class RestApi {
|
|||||||
response.validate();
|
response.validate();
|
||||||
}
|
}
|
||||||
return Response.ok(response).build();
|
return Response.ok(response).build();
|
||||||
|
} catch (TooManyRequestsException e) {
|
||||||
|
return Response.status(Status.TOO_MANY_REQUESTS).build();
|
||||||
} catch (TelegramApiValidationException e) {
|
} catch (TelegramApiValidationException e) {
|
||||||
log.error(e.getLocalizedMessage(), e);
|
log.error(e.getLocalizedMessage(), e);
|
||||||
return Response.serverError().build();
|
return Response.serverError().build();
|
||||||
@ -74,6 +77,8 @@ public class RestApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Response.ok(responses).build();
|
return Response.ok(responses).build();
|
||||||
|
} catch (TooManyRequestsException e) {
|
||||||
|
return Response.status(Status.TOO_MANY_REQUESTS).build();
|
||||||
} catch (TelegramApiValidationException e) {
|
} catch (TelegramApiValidationException e) {
|
||||||
log.error(e.getLocalizedMessage(), e);
|
log.error(e.getLocalizedMessage(), e);
|
||||||
return Response.serverError().build();
|
return Response.serverError().build();
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
package org.telegram.telegrambots.updatesreceivers;
|
||||||
|
|
||||||
|
public class TooManyRequestsException extends RuntimeException {}
|
Loading…
x
Reference in New Issue
Block a user