cn.lnkdoc.sdk.uia.instance.wx.util.CheckResponseUtil.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of awesome-uia-sdk Show documentation
Show all versions of awesome-uia-sdk Show documentation
Awesome Uia SDK for Java
Copyright © 2023 lnkdoc All rights reserved.
The newest version!
package cn.lnkdoc.sdk.uia.instance.wx.util
import cn.lnkdoc.sdk.uia.common.exception.UiaException
import cn.lnkdoc.sdk.uia.instance.wx.response.WxResponse
import com.alibaba.fastjson2.JSONObject
import com.alibaba.fastjson2.TypeReference
import org.slf4j.LoggerFactory
import java.util.*
/**
* @author langkye
* @since 1.0.0.RELEASE
*/
@Suppress("unused", "MemberVisibilityCanBePrivate")
object CheckResponseUtil {
private val log = LoggerFactory.getLogger(CheckResponseUtil::class.java)
/**
* check
*
* @param json json
*/
@Synchronized
fun check(json: String?) {
check(json, false)
}
/**
* check
*
* @param json json
* @param isPrintStack isPrintStack
*/
@Synchronized
fun check(json: String?, isPrintStack: Boolean?) {
val wxResponse = JSONObject.parseObject(json, object : TypeReference() {})
if (Objects.nonNull(wxResponse?.errcode)) {
if (isPrintStack == true) {
log.error(json)
}
throw UiaException(wxResponse?.errmsg)
}
}
}