Logging changes and cleanup

This commit is contained in:
Sollace 2022-11-25 19:50:52 +00:00
parent b4a3473567
commit 35eea7aa3a
4 changed files with 17 additions and 28 deletions

View file

@ -186,7 +186,7 @@ public class SkinUploader implements Closeable {
try {
gateway.performSkinUpload(new SkinUpload(mc.getSession(), skinType, localSkin == null ? null : localSkin.toURI(), skinMetadata));
setError("");
} catch (IOException | AuthenticationException e) {
} catch (Exception e) {
handleException(e);
}
}, HDSkinManager.skinUploadExecutor).thenRunAsync(this::fetchRemote);
@ -229,13 +229,7 @@ public class SkinUploader implements Closeable {
fetchingSkin = false;
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 if (throwable instanceof HttpException) {
if (throwable instanceof HttpException) {
HttpException ex = (HttpException)throwable;
int code = ex.getStatusCode();
@ -246,10 +240,22 @@ public class SkinUploader implements Closeable {
} else if (code >= 400 && code != 403 && code != 404) {
logger.error(ex.getReasonPhrase(), ex);
setError(ex.getReasonPhrase());
} else {
logger.error(ex.getReasonPhrase(), ex);
}
} else {
logger.error("Unhandled exception", throwable);
setError(throwable.toString());
logger.error("Unexpected error whilst contacting server at " + Objects.toString(gateway), throwable);
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());
}
}
}

View file

@ -44,10 +44,6 @@ public class BethlehemSkinServer implements SkinServer {
@Override
public TexturePayload loadProfileData(GameProfile profile) throws IOException {
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");
}
}

View file

@ -1,8 +1,5 @@
package com.voxelmodpack.hdskins.server;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import java.io.IOException;
public class HttpException extends IOException {
@ -12,14 +9,6 @@ public class HttpException extends IOException {
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) {
super("(" + statusCode + ") " + reason, cause);

View file

@ -88,9 +88,7 @@ public class LegacySkinServer implements SkinServer {
private MinecraftProfileTexture loadProfileTexture(GameProfile profile, String url) throws IOException {
try (MoreHttpResponses resp = MoreHttpResponses.execute(HTTP_CLIENT, new HttpHead(url))) {
if (!resp.ok()) {
throw new HttpException(resp.response());
}
resp.requireOk();
logger.debug("Found skin for {} at {}", profile.getName(), url);
Header eTagHeader = resp.response().getFirstHeader(HttpHeaders.ETAG);