commonMain.aws.sdk.kotlin.services.cloudsearch.serde.BaseExceptionDeserializer.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.cloudsearch.serde
import aws.sdk.kotlin.services.cloudsearch.model.BaseException
import aws.smithy.kotlin.runtime.http.HttpCall
import aws.smithy.kotlin.runtime.http.operation.HttpDeserialize
import aws.smithy.kotlin.runtime.http.readAll
import aws.smithy.kotlin.runtime.http.response.HttpResponse
import aws.smithy.kotlin.runtime.operation.ExecutionContext
import aws.smithy.kotlin.runtime.serde.SdkFieldDescriptor
import aws.smithy.kotlin.runtime.serde.SdkObjectDescriptor
import aws.smithy.kotlin.runtime.serde.SerialKind
import aws.smithy.kotlin.runtime.serde.deserializeStruct
import aws.smithy.kotlin.runtime.serde.getOrDeserializeErr
import aws.smithy.kotlin.runtime.serde.xml.tryData
import aws.smithy.kotlin.runtime.serde.xml.xmlTagReader
internal class BaseExceptionDeserializer: HttpDeserialize {
override suspend fun deserialize(context: ExecutionContext, call: HttpCall): BaseException {
val response = call.response
val builder = BaseException.Builder()
val payload = response.body.readAll()
if (payload != null) {
deserializeBaseExceptionError(builder, payload)
}
builder.correctErrors()
return builder.build()
}
}
internal fun deserializeBaseExceptionError(builder: BaseException.Builder, payload: ByteArray) {
val root = xmlTagReader(payload)
val errReader = unwrapWrappedXmlErrorResponse(root)
loop@while (true) {
val curr = errReader.nextTag() ?: break@loop
when (curr.tagName) {
// Code com.amazonaws.cloudsearch#BaseException$Code
"Code" -> builder.code = curr.tryData()
.getOrDeserializeErr { "expected (string: `com.amazonaws.cloudsearch#ErrorCode`)" }
// Message com.amazonaws.cloudsearch#BaseException$Message
"Message" -> builder.message = curr.tryData()
.getOrDeserializeErr { "expected (string: `com.amazonaws.cloudsearch#ErrorMessage`)" }
else -> {}
}
curr.drop()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy