handle errors from minecraftforge.net
japherwocky opened this issue ยท 3 comments
We're getting a ton of noise in our server logs from this:
[18:25:58] [MercuriusThread/INFO] [STDERR]: [net.minecraftforge.mercurius.Sender:post:160]: java.io.IOException: Server returned HTTP response code: 500 for URL: http://stats.minecraftforge.net/api/v2/
[18:25:58] [MercuriusThread/INFO] [STDERR]: [net.minecraftforge.mercurius.Sender:post:160]: at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
[18:25:58] [MercuriusThread/INFO] [STDERR]: [net.minecraftforge.mercurius.Sender:post:160]: at sun.net.www.protocol.http.HttpURLConnection.access$200(HttpURLConnection.java:91)
[18:25:58] [MercuriusThread/INFO] [STDERR]: [net.minecraftforge.mercurius.Sender:post:160]: at sun.net.www.protocol.http.HttpURLConnection$9.run(HttpURLConnection.java:1466)
[18:25:58] [MercuriusThread/INFO] [STDERR]: [net.minecraftforge.mercurius.Sender:post:160]: at sun.net.www.protocol.http.HttpURLConnection$9.run(HttpURLConnection.java:1464)
[18:25:58] [MercuriusThread/INFO] [STDERR]: [net.minecraftforge.mercurius.Sender:post:160]: at java.security.AccessController.doPrivileged(Native Method)
[18:25:58] [MercuriusThread/INFO] [STDERR]: [net.minecraftforge.mercurius.Sender:post:160]: at java.security.AccessController.doPrivilegedWithCombiner(AccessController.java:782)
[18:25:58] [MercuriusThread/INFO] [STDERR]: [net.minecraftforge.mercurius.Sender:post:160]: at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1463)
[18:25:58] [MercuriusThread/INFO] [STDERR]: [net.minecraftforge.mercurius.Sender:post:160]: at net.minecraftforge.mercurius.Sender.post(Sender.java:142)
[18:25:58] [MercuriusThread/INFO] [STDERR]: [net.minecraftforge.mercurius.Sender:post:160]: at net.minecraftforge.mercurius.Sender.access$000(Sender.java:26)
[18:25:58] [MercuriusThread/INFO] [STDERR]: [net.minecraftforge.mercurius.Sender:post:160]: at net.minecraftforge.mercurius.Sender$1.run(Sender.java:115)
I appreciate that the error is actually in the service at stats.minecraftforge.net, but could you maybe check the status code of the response and handle it more gracefully?
Pretty common when working with web apis is to do something like:
if response.status > 400:
error( 'the service at {{ response.url }} gave error code: {{ response.status }} )
(sorry, I write python/javascript!)
200 level codes mean success, 300 level means the URL changed, 400 means the URL is wrong, 500 means an error was on their end.
Usually URL fetching clients will automatically follow 300 level redirects, so the easiest thing to check is for codes > 400.
Fair call out. I'll take a look at it. :)
I'm familiar with HTTP response code family, though I prefer this way of describing them :D (joking of course)
1xx: hold on
2xx: here you go
3xx: go away
4xx: you fucked up
5xx: I fucked up
Fixed in 1.0.6. Errors will only be pushed to the log if spammyLogs config is enabled.