Catching HttpExceptions in own code
Drag0nDev opened this issue · 1 comments
Drag0nDev commented
Currently I use this library for logging by sending embeds to specified webhooks. But if the channels get remade and the new webhook link is still not replaced I get the following error.
Sending a webhook message failed with non-OK http response
club.minnced.discord.webhook.exception.HttpException: Request returned failure 404: {"message": "Unknown Webhook", "code": 10015}
at club.minnced.discord.webhook.WebhookClient.failure(WebhookClient.java:722)
at club.minnced.discord.webhook.WebhookClient.executePair(WebhookClient.java:797)
at club.minnced.discord.webhook.WebhookClient.drainQueue(WebhookClient.java:766)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:831)
Is there any way to catch these exceptions or have them not display in the log files?
MinnDevelopment commented
With the release of 0.8.0 you should be able to introduce custom error handling using WebhookClient#setDefaultErrorHandler. There is an example in the README. Individual requests return a CompletableFuture
which can handle exceptions using whenComplete
or exceptionally
on a per-future basis, however the exception is still printed by the default error handler.