Made webhook bots print exceptions stacktrace to stderr instead of silently swallowing them.

This commit is contained in:
Mouamle 2020-09-05 03:53:42 +03:00
parent e6b9fd892f
commit 6fcd4d85c1
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,20 @@
package org.telegram.telegrambots.updatesreceivers;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
/**
* Prints exceptions in webhook bots to stderr
*
* @author Mouamle
* @version 1.0
*/
public class DefaultExceptionMapper implements ExceptionMapper<Throwable> {
@Override
public Response toResponse(Throwable exception) {
exception.printStackTrace();
return Response.serverError().build();
}
}

View File

@ -52,6 +52,7 @@ public class DefaultWebhook implements Webhook {
ResourceConfig rc = new ResourceConfig();
rc.register(restApi);
rc.register(JacksonFeature.class);
rc.register(DefaultExceptionMapper.class);
final HttpServer grizzlyServer;
if (keystoreServerFile != null && keystoreServerPwd != null) {