From 1c6f624fd14fb6ea17a8a55e35e824ab21a1e8ee Mon Sep 17 00:00:00 2001 From: tarsin Date: Thu, 5 Jan 2023 21:21:47 +0800 Subject: [PATCH] Kotlinize EhExceptions --- .../ehviewer/client/exception/EhException.kt | 17 ++++-------- .../client/exception/Image509Exception.kt | 10 ++----- .../client/exception/NoHAtHClientException.kt | 11 ++------ .../client/exception/OffensiveException.kt | 10 ++----- .../client/exception/ParseException.kt | 27 ++++++++----------- .../client/exception/PiningException.kt | 10 ++----- 6 files changed, 24 insertions(+), 61 deletions(-) diff --git a/app/src/main/java/com/hippo/ehviewer/client/exception/EhException.kt b/app/src/main/java/com/hippo/ehviewer/client/exception/EhException.kt index 914bdbadf..aa5c9e747 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/exception/EhException.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/exception/EhException.kt @@ -13,16 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package com.hippo.ehviewer.client.exception -package com.hippo.ehviewer.client.exception; - -public class EhException extends Exception { - - public EhException(String detailMessage) { - super(detailMessage); - } - - public EhException(String detailMessage, Throwable cause) { - super(detailMessage, cause); - } -} +open class EhException : Exception { + constructor(detailMessage: String?) : super(detailMessage) + constructor(detailMessage: String?, cause: Throwable?) : super(detailMessage, cause) +} \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/client/exception/Image509Exception.kt b/app/src/main/java/com/hippo/ehviewer/client/exception/Image509Exception.kt index 495722598..dc3a03932 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/exception/Image509Exception.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/exception/Image509Exception.kt @@ -13,12 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package com.hippo.ehviewer.client.exception -package com.hippo.ehviewer.client.exception; - -public class Image509Exception extends EhException { - - public Image509Exception() { - super("509"); - } -} +class Image509Exception : EhException("509") \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/client/exception/NoHAtHClientException.kt b/app/src/main/java/com/hippo/ehviewer/client/exception/NoHAtHClientException.kt index 8cc627f3c..8efb54662 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/exception/NoHAtHClientException.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/exception/NoHAtHClientException.kt @@ -13,13 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package com.hippo.ehviewer.client.exception -package com.hippo.ehviewer.client.exception; - -public class NoHAtHClientException extends EhException { - - public NoHAtHClientException(String detailMessage) { - super(detailMessage); - } - -} +class NoHAtHClientException(detailMessage: String?) : EhException(detailMessage) \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/client/exception/OffensiveException.kt b/app/src/main/java/com/hippo/ehviewer/client/exception/OffensiveException.kt index b9ea8b33c..7675e0205 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/exception/OffensiveException.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/exception/OffensiveException.kt @@ -13,15 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -package com.hippo.ehviewer.client.exception; +package com.hippo.ehviewer.client.exception /** * It is an exception for get offensive tip for g.e-hentai.org */ -public class OffensiveException extends EhException { - - public OffensiveException() { - super("OFFENSIVE"); - } -} +class OffensiveException : EhException("OFFENSIVE") \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/client/exception/ParseException.kt b/app/src/main/java/com/hippo/ehviewer/client/exception/ParseException.kt index fa535b04d..27860c007 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/exception/ParseException.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/exception/ParseException.kt @@ -13,24 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package com.hippo.ehviewer.client.exception -package com.hippo.ehviewer.client.exception; +class ParseException : EhException { + val body: String -public class ParseException extends EhException { - - private final String mBody; - - public ParseException(String detailMessage, String body) { - super(detailMessage); - mBody = body; + constructor(detailMessage: String?, body: String) : super(detailMessage) { + this.body = body } - public ParseException(String detailMessage, String body, Throwable cause) { - super(detailMessage, cause); - mBody = body; + constructor(detailMessage: String?, body: String, cause: Throwable?) : super( + detailMessage, + cause + ) { + this.body = body } - - public String getBody() { - return mBody; - } -} +} \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/client/exception/PiningException.kt b/app/src/main/java/com/hippo/ehviewer/client/exception/PiningException.kt index 828521e38..00283bcab 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/exception/PiningException.kt +++ b/app/src/main/java/com/hippo/ehviewer/client/exception/PiningException.kt @@ -13,12 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package com.hippo.ehviewer.client.exception -package com.hippo.ehviewer.client.exception; - -public class PiningException extends EhException { - - public PiningException() { - super("pining for the fjords"); - } -} +class PiningException : EhException("pining for the fjords") \ No newline at end of file