diff options
| author | syeyoung <cyoung06@naver.com> | 2022-11-17 00:02:21 +0900 |
|---|---|---|
| committer | syeyoung <cyoung06@naver.com> | 2022-11-17 00:12:48 +0900 |
| commit | d07321fe03f6316f28d8421b7cd4e93dfdfd6b2e (patch) | |
| tree | ae5b92754216c0a660a826ef8d208ce1b0fd2ced /loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions | |
| parent | ff17b30c4b585622ca3b8e06eb77794aa21f4285 (diff) | |
| download | Skyblock-Dungeons-Guide-d07321fe03f6316f28d8421b7cd4e93dfdfd6b2e.tar.gz Skyblock-Dungeons-Guide-d07321fe03f6316f28d8421b7cd4e93dfdfd6b2e.tar.bz2 Skyblock-Dungeons-Guide-d07321fe03f6316f28d8421b7cd4e93dfdfd6b2e.zip | |
- Better Exception handling
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions')
9 files changed, 42 insertions, 18 deletions
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/DungeonsGuideLoadingException.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/DungeonsGuideLoadingException.java new file mode 100644 index 00000000..07f72d40 --- /dev/null +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/DungeonsGuideLoadingException.java @@ -0,0 +1,7 @@ +package kr.syeyoung.dungeonsguide.launcher.exceptions; + +public class DungeonsGuideLoadingException extends Exception { + public DungeonsGuideLoadingException(String message) {super(message);} + public DungeonsGuideLoadingException(Throwable cause) {super(cause);} + public DungeonsGuideLoadingException(String message, Throwable cause) {super(message, cause);} +} diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/NoSuitableLoaderFoundException.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/NoSuitableLoaderFoundException.java index c2f9a907..2f6665d5 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/NoSuitableLoaderFoundException.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/NoSuitableLoaderFoundException.java @@ -20,7 +20,7 @@ package kr.syeyoung.dungeonsguide.launcher.exceptions; import lombok.AllArgsConstructor; -public class NoSuitableLoaderFoundException extends RuntimeException { +public class NoSuitableLoaderFoundException extends Exception { private String jvmFlag; private String configuration; diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/NoVersionFoundException.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/NoVersionFoundException.java index b99d12c1..b5b39f32 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/NoVersionFoundException.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/NoVersionFoundException.java @@ -21,17 +21,17 @@ package kr.syeyoung.dungeonsguide.launcher.exceptions; import lombok.Getter; @Getter -public class NoVersionFoundException extends RuntimeException { +public class NoVersionFoundException extends Exception { private String branch; private String version; - public NoVersionFoundException(String branch, String version) { - super("No version found: "+branch+" - "+version); + public NoVersionFoundException(String branch, String version, String payload) { + super("No version found: "+branch+" - "+version+"\n Additional Data: "+payload); this.branch = branch; this.version = version; } - public NoVersionFoundException(String branch, String version, Throwable e) { - super("No version found: "+branch+" - "+version, e); + public NoVersionFoundException(String branch, String version, String payload, Throwable e) { + super("No version found: "+branch+" - "+version+"\n Additional Data: "+payload+"\n "+e.toString(), e); this.branch = branch; this.version = version; } diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/AuthFailedExeption.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/auth/AuthFailedExeption.java index d860afb6..25a97353 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/AuthFailedExeption.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/auth/AuthFailedExeption.java @@ -1,4 +1,4 @@ -package kr.syeyoung.dungeonsguide.launcher.exceptions; +package kr.syeyoung.dungeonsguide.launcher.exceptions.auth; public class AuthFailedExeption extends AuthenticationUnavailableException { public AuthFailedExeption(Throwable cause) { diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/AuthenticationUnavailableException.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/auth/AuthenticationUnavailableException.java index a42ddd93..674b26d6 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/AuthenticationUnavailableException.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/auth/AuthenticationUnavailableException.java @@ -1,4 +1,4 @@ -package kr.syeyoung.dungeonsguide.launcher.exceptions; +package kr.syeyoung.dungeonsguide.launcher.exceptions.auth; public class AuthenticationUnavailableException extends RuntimeException { public AuthenticationUnavailableException(Throwable cause){ diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/PrivacyPolicyRequiredException.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/auth/PrivacyPolicyRequiredException.java index a48632dc..3eee30a5 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/PrivacyPolicyRequiredException.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/auth/PrivacyPolicyRequiredException.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package kr.syeyoung.dungeonsguide.launcher.exceptions; +package kr.syeyoung.dungeonsguide.launcher.exceptions.auth; public class PrivacyPolicyRequiredException extends AuthenticationUnavailableException { } diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/TokenExpiredException.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/auth/TokenExpiredException.java index 4826b1ba..0f71507c 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/TokenExpiredException.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/auth/TokenExpiredException.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package kr.syeyoung.dungeonsguide.launcher.exceptions; +package kr.syeyoung.dungeonsguide.launcher.exceptions.auth; public class TokenExpiredException extends AuthenticationUnavailableException { diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/AuthServerException.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/http/AuthServerException.java index 67647b9b..7784e3ee 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/AuthServerException.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/http/AuthServerException.java @@ -16,23 +16,26 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package kr.syeyoung.dungeonsguide.launcher.exceptions; +package kr.syeyoung.dungeonsguide.launcher.exceptions.http; import kr.syeyoung.dungeonsguide.launcher.auth.DGResponse; -import kr.syeyoung.dungeonsguide.launcher.util.QRCodeGenerator; -import org.json.JSONObject; - -import java.util.Objects; +import kr.syeyoung.dungeonsguide.launcher.exceptions.auth.AuthenticationUnavailableException; public class AuthServerException extends AuthenticationUnavailableException { private DGResponse response; public AuthServerException(DGResponse response) { - super(response.getErrorMessage() == null ? "Invalid Server Response" : response.getErrorMessage()); + super(response.getErrorMessage()); this.response = response; } public String getQRCode() { return response.getQrCode() == null ? null : response.getQrCode(); } + + + @Override + public String toString() { + return super.toString()+"\n Server ResponseCode: "+response.getResponseCode(); + } } diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/ResponseParsingException.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/http/ResponseParsingException.java index 3933b78e..59454e17 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/ResponseParsingException.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/http/ResponseParsingException.java @@ -16,18 +16,32 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package kr.syeyoung.dungeonsguide.launcher.exceptions; +package kr.syeyoung.dungeonsguide.launcher.exceptions.http; import lombok.Getter; import org.json.JSONObject; public class ResponseParsingException extends RuntimeException { @Getter - private String payload; + private final String payload; + + public ResponseParsingException(String payload, Exception e) { + super(e); + this.payload = payload; + } + + public ResponseParsingException(String payload, String message, Exception e) { + super(message, e); + this.payload = payload; + } public ResponseParsingException(String payload, String message) { super(message); this.payload = payload; } + @Override + public String toString() { + return super.toString()+"\n Problematic Message: "+payload; + } } |
