Merge pull request #801 from MouamleH/dev
Webhook bots now print exceptions instead of ignoring them
This commit is contained in:
commit
7336766502
@ -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();
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user