Merge pull request #801 from MouamleH/dev

Webhook bots now print exceptions instead of ignoring them
This commit is contained in:
Ruben Bermudez 2020-10-21 19:32:46 +01:00 committed by GitHub
commit 7336766502
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package org.telegram.telegrambots.updatesreceivers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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> {
private static final Logger log = LoggerFactory.getLogger(DefaultExceptionMapper.class);
@Override
public Response toResponse(Throwable exception) {
log.error("Exception caught: ", exception);
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) {