From 6f3b6a12d9cebc75ada91fb25a5bab9198a20b07 Mon Sep 17 00:00:00 2001 From: Edoardo La Greca Date: Thu, 7 Aug 2025 20:01:21 +0200 Subject: move InvalidMessageException to except package --- src/main/kotlin/Connection.kt | 2 +- src/main/kotlin/InMessage.kt | 3 ++- src/main/kotlin/InvalidMessageException.kt | 6 ------ src/main/kotlin/ProtocolTranslator.kt | 2 +- src/main/kotlin/except/InvalidMessageException.kt | 8 ++++++++ 5 files changed, 12 insertions(+), 9 deletions(-) delete mode 100644 src/main/kotlin/InvalidMessageException.kt create mode 100644 src/main/kotlin/except/InvalidMessageException.kt diff --git a/src/main/kotlin/Connection.kt b/src/main/kotlin/Connection.kt index a0923e8..9982e76 100644 --- a/src/main/kotlin/Connection.kt +++ b/src/main/kotlin/Connection.kt @@ -60,7 +60,7 @@ class Connection(transLay: TransportLayer) : ProtocolTranslator { * @return A pair of: (1) a nullable string (which can be: `null` if no error occurred, empty if an error occurred * with no message, or non-empty with the error message) and (2) the optional [InMessage] instance (null if an error * occurred). - * @throws InvalidMessageException if the received message is invalid. + * @throws except.InvalidMessageException if the received message is invalid. * @throws RErrorException if the received message is an R-error message. */ private fun checkedInMessage(reqTag: UShort): InMessage { diff --git a/src/main/kotlin/InMessage.kt b/src/main/kotlin/InMessage.kt index 03f3428..bf76ef9 100644 --- a/src/main/kotlin/InMessage.kt +++ b/src/main/kotlin/InMessage.kt @@ -1,3 +1,4 @@ +import except.InvalidMessageException import java.math.BigInteger /** @@ -7,7 +8,7 @@ import java.math.BigInteger * @param tl The transport layer API. * @param maxSize The maximum message size negotiated with the remote part. * @param reqTag The required tag. - * @throws InvalidMessageException if the message that is currently being read is invalid. + * @throws except.InvalidMessageException if the message that is currently being read is invalid. */ class InMessage(val tl: TransportLayer, maxSize: UInt, val reqTag: UShort) { /** diff --git a/src/main/kotlin/InvalidMessageException.kt b/src/main/kotlin/InvalidMessageException.kt deleted file mode 100644 index 5b29edf..0000000 --- a/src/main/kotlin/InvalidMessageException.kt +++ /dev/null @@ -1,6 +0,0 @@ -/** - * The packet that is currently being read is not valid. - * - * @param reason The reason for which the packet is invalid. - */ -class InvalidMessageException(val reason: String) : Exception("Invalid packet: $reason") \ No newline at end of file diff --git a/src/main/kotlin/ProtocolTranslator.kt b/src/main/kotlin/ProtocolTranslator.kt index f7b114f..686e05e 100644 --- a/src/main/kotlin/ProtocolTranslator.kt +++ b/src/main/kotlin/ProtocolTranslator.kt @@ -27,7 +27,7 @@ interface ProtocolTranslator { * @param msize The maximum length, in bytes, that the client will ever generate or expect to receive in a single * 9P message. * @param version Should be "9P2000", which is the only defined value. - * @throws InvalidMessageException if the received message is invalid. + * @throws except.InvalidMessageException if the received message is invalid. * @throws RErrorException if the received message is an R-error message. * @throws MsizeValueTooBigException if the received `msize` value is bigger than what the client requested. * @throws UnknownVersionException if the version negotiation failed. diff --git a/src/main/kotlin/except/InvalidMessageException.kt b/src/main/kotlin/except/InvalidMessageException.kt new file mode 100644 index 0000000..02a3cc4 --- /dev/null +++ b/src/main/kotlin/except/InvalidMessageException.kt @@ -0,0 +1,8 @@ +package except + +/** + * The packet that is currently being read is not valid. + * + * @param reason The reason for which the packet is invalid. + */ +class InvalidMessageException(val reason: String) : Exception("Invalid packet: $reason") \ No newline at end of file -- cgit v1.2.3