From 7341ead2aade10ea1b833e94275277658741883a Mon Sep 17 00:00:00 2001 From: Edoardo La Greca Date: Mon, 18 Aug 2025 21:09:11 +0200 Subject: switch to multi-module project structure --- lib/src/main/kotlin/except/FailedAuthenticationException.kt | 8 ++++++++ lib/src/main/kotlin/except/InvalidMessageException.kt | 8 ++++++++ lib/src/main/kotlin/except/MsizeValueTooBigException.kt | 10 ++++++++++ lib/src/main/kotlin/except/RErrorException.kt | 8 ++++++++ lib/src/main/kotlin/except/UnaccessibleFileException.kt | 11 +++++++++++ lib/src/main/kotlin/except/UnknownVersionException.kt | 9 +++++++++ lib/src/main/kotlin/except/UnresolvableHostException.kt | 8 ++++++++ 7 files changed, 62 insertions(+) create mode 100644 lib/src/main/kotlin/except/FailedAuthenticationException.kt create mode 100644 lib/src/main/kotlin/except/InvalidMessageException.kt create mode 100644 lib/src/main/kotlin/except/MsizeValueTooBigException.kt create mode 100644 lib/src/main/kotlin/except/RErrorException.kt create mode 100644 lib/src/main/kotlin/except/UnaccessibleFileException.kt create mode 100644 lib/src/main/kotlin/except/UnknownVersionException.kt create mode 100644 lib/src/main/kotlin/except/UnresolvableHostException.kt (limited to 'lib/src/main/kotlin/except') diff --git a/lib/src/main/kotlin/except/FailedAuthenticationException.kt b/lib/src/main/kotlin/except/FailedAuthenticationException.kt new file mode 100644 index 0000000..94935c3 --- /dev/null +++ b/lib/src/main/kotlin/except/FailedAuthenticationException.kt @@ -0,0 +1,8 @@ +package except + +/** + * The authentication with the remote part failed. + * + * @param reason A human-readable reason for which the authentication failed. + */ +class FailedAuthenticationException(val reason: String) : Exception("Authentication with remote host failed: $reason") \ No newline at end of file diff --git a/lib/src/main/kotlin/except/InvalidMessageException.kt b/lib/src/main/kotlin/except/InvalidMessageException.kt new file mode 100644 index 0000000..02a3cc4 --- /dev/null +++ b/lib/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 diff --git a/lib/src/main/kotlin/except/MsizeValueTooBigException.kt b/lib/src/main/kotlin/except/MsizeValueTooBigException.kt new file mode 100644 index 0000000..f1f6da1 --- /dev/null +++ b/lib/src/main/kotlin/except/MsizeValueTooBigException.kt @@ -0,0 +1,10 @@ +package except + +/** + * This exception is thrown when the `msize` value sent by the server is bigger than that sent by the client during the + * version transaction. + * + * @param maxClientValue The value requested by the client. + * @param receivedValue The value sent by the server. + */ +class MsizeValueTooBigException(val maxClientValue: UInt, val receivedValue: UInt) : Exception("Msize value too big: $receivedValue > $maxClientValue") \ No newline at end of file diff --git a/lib/src/main/kotlin/except/RErrorException.kt b/lib/src/main/kotlin/except/RErrorException.kt new file mode 100644 index 0000000..c15cbc2 --- /dev/null +++ b/lib/src/main/kotlin/except/RErrorException.kt @@ -0,0 +1,8 @@ +package except + +/** + * This exception represents an error sent by the remote server as an R-error message. + * + * @param message The message sent by the server. + */ +class RErrorException(val rErrorMessage: String?) : Exception("R-error message received: $rErrorMessage") \ No newline at end of file diff --git a/lib/src/main/kotlin/except/UnaccessibleFileException.kt b/lib/src/main/kotlin/except/UnaccessibleFileException.kt new file mode 100644 index 0000000..07d5d13 --- /dev/null +++ b/lib/src/main/kotlin/except/UnaccessibleFileException.kt @@ -0,0 +1,11 @@ +package except + +/** + * This exception is thrown when the file that the client is trying to open (or walk through, in case of a directory) + * cannot be accessed. + * + * @param path The path, as a list of path elements, that the client tried to access, up to and including the first + * element that cannot be accessed (e.g. if the path the user wants to access is `["usr", "foo", "bar", "zib"]` but + * `bar` does not exist, then [path] must be `["usr", "foo", "bar"]`). + */ +class UnaccessibleFileException(val path: List) : Exception("Could not walk to file ${path.joinToString(separator = "/")}.") \ No newline at end of file diff --git a/lib/src/main/kotlin/except/UnknownVersionException.kt b/lib/src/main/kotlin/except/UnknownVersionException.kt new file mode 100644 index 0000000..5023bc5 --- /dev/null +++ b/lib/src/main/kotlin/except/UnknownVersionException.kt @@ -0,0 +1,9 @@ +package except + +/** + * This exception is thrown when the remote server sent either an "unknown" version back during the version negotiation + * procedure or a version unknown to this client implementation. + * + * @param version The version sent by the server. + */ +class UnknownVersionException(val version: String) : Exception("Unknown version: $version") \ No newline at end of file diff --git a/lib/src/main/kotlin/except/UnresolvableHostException.kt b/lib/src/main/kotlin/except/UnresolvableHostException.kt new file mode 100644 index 0000000..19dd3b6 --- /dev/null +++ b/lib/src/main/kotlin/except/UnresolvableHostException.kt @@ -0,0 +1,8 @@ +package except + +/** + * The specified domain, which identifies the host's address, could not be resolved. + * + * @param address The unresolvable address. + */ +class UnresolvableHostException(val address: String) : Exception("Hostname $address unresolvable.") \ No newline at end of file -- cgit v1.2.3