-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
88 additions
and
30 deletions.
There are no files selected for viewing
71 changes: 57 additions & 14 deletions
71
kirc-core/src/main/kotlin/de/cmdjulian/kirc/exception/RegistryClientException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,86 @@ | ||
package de.cmdjulian.kirc.exception | ||
|
||
sealed class RegistryClientException(override val message: String, throwable: Throwable? = null) : | ||
RuntimeException(message, throwable) { | ||
import de.cmdjulian.kirc.image.Reference | ||
import de.cmdjulian.kirc.image.Repository | ||
import java.net.URL | ||
|
||
sealed class ClientException(message: String, val error: ErrorResponse?, cause: Throwable) : | ||
RegistryClientException(message, cause) { | ||
sealed class RegistryClientException( | ||
val url: URL, | ||
val repository: Repository?, | ||
val reference: Reference?, | ||
override val message: String, | ||
throwable: Throwable? = null, | ||
) : RuntimeException(message, throwable) { | ||
|
||
class AuthenticationException(error: ErrorResponse?, cause: Throwable) : | ||
ClientException("authentication required", error, cause) { | ||
sealed class ClientException( | ||
url: URL, | ||
repository: Repository?, | ||
reference: Reference?, | ||
message: String, | ||
val error: ErrorResponse?, | ||
cause: Throwable, | ||
) : RegistryClientException(url, repository, reference, message, cause) { | ||
|
||
class AuthenticationException( | ||
url: URL, | ||
repository: Repository?, | ||
reference: Reference?, | ||
error: ErrorResponse?, | ||
cause: Throwable, | ||
) : ClientException(url, repository, reference, "authentication required", error, cause) { | ||
override fun toString(): String = "DistributionClientException.AuthenticationError -> $message" | ||
} | ||
|
||
class AuthorizationException(error: ErrorResponse?, cause: Throwable) : | ||
ClientException("authorization required", error, cause) { | ||
class AuthorizationException( | ||
url: URL, | ||
repository: Repository?, | ||
reference: Reference?, | ||
error: ErrorResponse?, | ||
cause: Throwable, | ||
) : ClientException(url, repository, reference, "authorization required", error, cause) { | ||
override fun toString(): String = "DistributionClientException.AuthorizationError -> $message" | ||
} | ||
|
||
class NotFoundException(error: ErrorResponse?, cause: Throwable) : ClientException("not found", error, cause) { | ||
class NotFoundException( | ||
url: URL, | ||
repository: Repository?, | ||
reference: Reference?, | ||
error: ErrorResponse?, | ||
cause: Throwable, | ||
) : ClientException(url, repository, reference, "not found", error, cause) { | ||
override fun toString(): String = "DistributionClientException.NotFoundException -> $message" | ||
} | ||
|
||
class MethodNotAllowed( | ||
url: URL, | ||
repository: Repository?, | ||
reference: Reference?, | ||
error: ErrorResponse?, | ||
cause: Throwable, | ||
) : ClientException("method not allowed", error, cause) { | ||
) : ClientException(url, repository, reference, "method not allowed", error, cause) { | ||
override fun toString() = "ClientException.MethodNotAllowed (is registry delete enabled?) -> $message" | ||
} | ||
|
||
class UnexpectedErrorException(error: ErrorResponse?, cause: Throwable) : | ||
ClientException("unknown error returned by server", error, cause) { | ||
class UnexpectedErrorException( | ||
url: URL, | ||
repository: Repository?, | ||
reference: Reference?, | ||
error: ErrorResponse?, | ||
cause: Throwable, | ||
) : ClientException(url, repository, reference, "unknown error returned by server", error, cause) { | ||
override fun toString(): String = "DistributionClientException.UnexpectedErrorException -> $message" | ||
} | ||
} | ||
|
||
class NetworkErrorException(t: Throwable) : RegistryClientException("Network error on registry connect", t) { | ||
class NetworkErrorException(url: URL, repository: Repository?, reference: Reference?, t: Throwable) : | ||
RegistryClientException(url, repository, reference, "Network error on registry connect", t) { | ||
|
||
override fun toString(): String = "DistributionClientException.NetworkError -> $message" | ||
} | ||
|
||
class UnknownErrorException(t: Throwable) : RegistryClientException("An unknown error occurred", t) { | ||
class UnknownErrorException(url: URL, repository: Repository?, reference: Reference?, t: Throwable) : | ||
RegistryClientException(url, repository, reference, "An unknown error occurred", t) { | ||
|
||
override fun toString(): String = "DistributionClientException.UnknownError -> $message" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters