Event for when JDA encounters an exception
See original GitHub issueTake errors such as below and turn it into an event so we can deal with it as we’d like instead of it forcibly being pushed to the console as stack traces tend to scare people who don’t know what they are/shouldn’t need to be concerned with them.
[Mon, 3. Apr 2017 19:47:32 ERROR] [JDA] Encountered an exception:
[Mon, 3. Apr 2017 19:47:32 ERROR] [JDA] com.mashape.unirest.http.exceptions.UnirestException: java.net.SocketException: Connection reset
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:143)
at com.mashape.unirest.request.BaseRequest.asString(BaseRequest.java:56)
at github.scarsz.discordsrv.dependancies.jda.core.requests.Requester.execute(Requester.java:122)
at github.scarsz.discordsrv.dependancies.jda.core.requests.ratelimit.BotRateLimiter$Bucket.run(BotRateLimiter.java:301)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.security.ssl.InputRecord.readFully(Unknown Source)
at sun.security.ssl.InputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
at sun.security.ssl.AppInputStream.read(Unknown Source)
at github.scarsz.discordsrv.dependancies.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139)
at github.scarsz.discordsrv.dependancies.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:155)
at github.scarsz.discordsrv.dependancies.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:284)
at github.scarsz.discordsrv.dependancies.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)
at github.scarsz.discordsrv.dependancies.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)
at github.scarsz.discordsrv.dependancies.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261)
at github.scarsz.discordsrv.dependancies.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165)
at github.scarsz.discordsrv.dependancies.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167)
at github.scarsz.discordsrv.dependancies.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272)
at github.scarsz.discordsrv.dependancies.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124)
at github.scarsz.discordsrv.dependancies.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)
at github.scarsz.discordsrv.dependancies.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at github.scarsz.discordsrv.dependancies.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at github.scarsz.discordsrv.dependancies.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at github.scarsz.discordsrv.dependancies.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at github.scarsz.discordsrv.dependancies.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at github.scarsz.discordsrv.dependancies.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
at github.scarsz.discordsrv.dependancies.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:138)
... 10 more
[Mon, 3. Apr 2017 19:47:32 ERROR] [JDA] RestAction queue returned failure: [ErrorResponseException] Discord returned an error with no defined error-code : null
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
ExceptionEvent (JDA 4.4.0_352 API)
public class ExceptionEvent extends Event. Indicates that JDA encountered a Throwable that could not be forwarded to another end-user frontend.
Read more >net.dv8tion.jda.core.events.ExceptionEvent java code examples ...
Indicates that JDA encountered a Throwable that could not be forwarded to another end-user frontend. ... It is not recommended to simply use...
Read more >Exception in thread "main" java.lang.IllegalArgumentException
Your issue is that you added new Commands() as your event listener. Your class is called testcommand so you have to do addEventListeners(new ......
Read more >AppDomain.UnhandledException Event - Microsoft Learn
This event provides notification of uncaught exceptions. It allows the application to log information about the exception before the system default handler ...
Read more >net.dv8tion.jda.api.events.GenericEvent Java Examples
This page shows Java code examples of net.dv8tion.jda.api.events.GenericEvent. ... LOG.error("Encountered exception trying to schedule event", ex); } }.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Exceptions and errors that are caught by JDA internals are passed into respective sections of the API. This means you can handle them through the
ExceptionEvent
or forRestAction
with the failure callbacks. The logging of timeouts and requester errors is intentional behavior and I don’t want to change it since it seems unnecessary and misleading. Timeouts and HTTP issues should be at a minimum for proper functioning communication anyway, if an issue rises it should most certainly be logged including the stacktrace for better issue prevention. JDA attempts to retry on an HTTP timeout once if it occurs, if that retry fails as well we will print the timeout exception to alert the end user of the faulty connection. Since JDA makes use of the SLF4J api it is possible to configure the logger to ignore or filter out any exception, although I highly discourage from ignoring them.My mentioned concerns and the fact this issue has been stale for such a long time are reason enough to close the thread.
Having an
ErrorHandler
interface might be an effective implementation for this.JDABuilder::setErrorHandler
, have the default/unspecified behavior be to an implementation that reflects JDA’s current behavior.