commonMain.com.huawei.hilink.c2c.integration.helper.Exceptions.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of helper-jvm Show documentation
Show all versions of helper-jvm Show documentation
The helper library streamlines the HiLink C2C integration and exposes a simple API.
package com.huawei.hilink.c2c.integration.helper
/**
* Thrown when [com.huawei.hilink.c2c.integration.helper.api.HttpRequestMaker]'s methods get their
* [com.huawei.hilink.c2c.integration.helper.api.ResultConsumer.onError] methods called.
* Indicates that partner implementation needs to be reviewed.
*/
internal class HttpRequestMakingException : Exception()
/**
* Thrown when AT used in HiLink cloud's request is either invalid or expired.
*/
internal class UnauthorizedException : Exception()
/**
* Thrown when AT used in HiLink cloud's request is not valid and CP want's to
* signalize that using RT makes no sense, as it reject the request totally and wants
* account linking to be dropped.
*/
internal class IllegalAccessException : Exception()
internal class PartnerImplCrashException(val crashSite: String) : Exception() {
override val message: String
get() = "An exception was thrown in $crashSite"
}
internal class PartnerImplErrorException(val errorSite: String, val messageFromCP: String) : Exception() {
override val message: String
get() = "consumer.onError() called in $errorSite with message: $messageFromCP"
}
/**
* thrown when partner implementation provides the helper with a parameter of an incorrect length.
*/
internal class ParamLenViolationException(
val violationSite: String,
val affectedParamName: String,
val limitType: LimitType,
val limit: Int,
) : Exception() {
override val message: String
get() = "Param len violation at $violationSite, for param: $affectedParamName where length should be $limitType $limit characters"
}
internal enum class LimitType {
UP_TO,
EXACTLY
}