mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-03-28 06:17:44 +01:00
Logging changes and cleanup
This commit is contained in:
parent
b4a3473567
commit
35eea7aa3a
4 changed files with 17 additions and 28 deletions
|
@ -186,7 +186,7 @@ public class SkinUploader implements Closeable {
|
||||||
try {
|
try {
|
||||||
gateway.performSkinUpload(new SkinUpload(mc.getSession(), skinType, localSkin == null ? null : localSkin.toURI(), skinMetadata));
|
gateway.performSkinUpload(new SkinUpload(mc.getSession(), skinType, localSkin == null ? null : localSkin.toURI(), skinMetadata));
|
||||||
setError("");
|
setError("");
|
||||||
} catch (IOException | AuthenticationException e) {
|
} catch (Exception e) {
|
||||||
handleException(e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
}, HDSkinManager.skinUploadExecutor).thenRunAsync(this::fetchRemote);
|
}, HDSkinManager.skinUploadExecutor).thenRunAsync(this::fetchRemote);
|
||||||
|
@ -229,13 +229,7 @@ public class SkinUploader implements Closeable {
|
||||||
|
|
||||||
fetchingSkin = false;
|
fetchingSkin = false;
|
||||||
|
|
||||||
if (throwable instanceof AuthenticationUnavailableException) {
|
if (throwable instanceof HttpException) {
|
||||||
offline = true;
|
|
||||||
} else if (throwable instanceof InvalidCredentialsException) {
|
|
||||||
setError("Invalid session: Please try restarting Minecraft");
|
|
||||||
} else if (throwable instanceof AuthenticationException) {
|
|
||||||
throttlingNeck = true;
|
|
||||||
} else if (throwable instanceof HttpException) {
|
|
||||||
HttpException ex = (HttpException)throwable;
|
HttpException ex = (HttpException)throwable;
|
||||||
|
|
||||||
int code = ex.getStatusCode();
|
int code = ex.getStatusCode();
|
||||||
|
@ -246,10 +240,22 @@ public class SkinUploader implements Closeable {
|
||||||
} else if (code >= 400 && code != 403 && code != 404) {
|
} else if (code >= 400 && code != 403 && code != 404) {
|
||||||
logger.error(ex.getReasonPhrase(), ex);
|
logger.error(ex.getReasonPhrase(), ex);
|
||||||
setError(ex.getReasonPhrase());
|
setError(ex.getReasonPhrase());
|
||||||
|
} else {
|
||||||
|
logger.error(ex.getReasonPhrase(), ex);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.error("Unhandled exception", throwable);
|
logger.error("Unexpected error whilst contacting server at " + Objects.toString(gateway), throwable);
|
||||||
setError(throwable.toString());
|
|
||||||
|
if (throwable instanceof AuthenticationUnavailableException) {
|
||||||
|
offline = true;
|
||||||
|
} else if (throwable instanceof InvalidCredentialsException) {
|
||||||
|
setError("Invalid session: Please try restarting Minecraft");
|
||||||
|
} else if (throwable instanceof AuthenticationException) {
|
||||||
|
throttlingNeck = true;
|
||||||
|
} else {
|
||||||
|
logger.error("Unhandled exception", throwable);
|
||||||
|
setError(throwable.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,6 @@ public class BethlehemSkinServer implements SkinServer {
|
||||||
@Override
|
@Override
|
||||||
public TexturePayload loadProfileData(GameProfile profile) throws IOException {
|
public TexturePayload loadProfileData(GameProfile profile) throws IOException {
|
||||||
try (MoreHttpResponses response = new NetClient("GET", getPath(profile)).send()) {
|
try (MoreHttpResponses response = new NetClient("GET", getPath(profile)).send()) {
|
||||||
if (!response.ok()) {
|
|
||||||
throw new HttpException(response.response());
|
|
||||||
}
|
|
||||||
|
|
||||||
return response.requireOk().json(TexturePayload.class, "Invalid texture payload");
|
return response.requireOk().json(TexturePayload.class, "Invalid texture payload");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package com.voxelmodpack.hdskins.server;
|
package com.voxelmodpack.hdskins.server;
|
||||||
|
|
||||||
import org.apache.http.HttpResponse;
|
|
||||||
import org.apache.http.StatusLine;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class HttpException extends IOException {
|
public class HttpException extends IOException {
|
||||||
|
@ -12,14 +9,6 @@ public class HttpException extends IOException {
|
||||||
|
|
||||||
private final int statusCode;
|
private final int statusCode;
|
||||||
|
|
||||||
public HttpException(HttpResponse response) {
|
|
||||||
this(response.getStatusLine());
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpException(StatusLine status) {
|
|
||||||
this(status.getReasonPhrase(), status.getStatusCode(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpException(String reason, int statusCode, Throwable cause) {
|
public HttpException(String reason, int statusCode, Throwable cause) {
|
||||||
super("(" + statusCode + ") " + reason, cause);
|
super("(" + statusCode + ") " + reason, cause);
|
||||||
|
|
||||||
|
|
|
@ -88,9 +88,7 @@ public class LegacySkinServer implements SkinServer {
|
||||||
|
|
||||||
private MinecraftProfileTexture loadProfileTexture(GameProfile profile, String url) throws IOException {
|
private MinecraftProfileTexture loadProfileTexture(GameProfile profile, String url) throws IOException {
|
||||||
try (MoreHttpResponses resp = MoreHttpResponses.execute(HTTP_CLIENT, new HttpHead(url))) {
|
try (MoreHttpResponses resp = MoreHttpResponses.execute(HTTP_CLIENT, new HttpHead(url))) {
|
||||||
if (!resp.ok()) {
|
resp.requireOk();
|
||||||
throw new HttpException(resp.response());
|
|
||||||
}
|
|
||||||
logger.debug("Found skin for {} at {}", profile.getName(), url);
|
logger.debug("Found skin for {} at {}", profile.getName(), url);
|
||||||
|
|
||||||
Header eTagHeader = resp.response().getFirstHeader(HttpHeaders.ETAG);
|
Header eTagHeader = resp.response().getFirstHeader(HttpHeaders.ETAG);
|
||||||
|
|
Loading…
Add table
Reference in a new issue