Skip to content

Commit

Permalink
优化异常日志打印
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzicheng committed Jul 25, 2023
1 parent ae5995a commit c04289c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ object CxHttpHelper {
return contentType.toMediaType()
}

internal fun exToMessage(ex: Exception): String {
@InternalAPI
fun exToMessage(ex: Exception): String {
if(debugLog){
ex.printStackTrace()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ inline fun <reified T, reified RESULT: CxHttpResult<T>> Response.result(): RESUL
try {
converter.convertResult(body, RESULT::class.java, T::class.java)
} catch (ex: Exception) {
CxHttpHelper.exToMessage(ex)
converter.convertResult(CxHttpHelper.FAILURE_CODE.toString(), "数据解析异常", resultType=RESULT::class.java)
}
} else {
Expand All @@ -39,6 +40,7 @@ inline fun <reified T, reified RESULT: CxHttpResult<List<T>>> Response.resultLis
try {
converter.convertResultList(body, RESULT::class.java, T::class.java)
} catch (ex: Exception) {
CxHttpHelper.exToMessage(ex)
converter.convertResult(CxHttpHelper.FAILURE_CODE.toString(), "数据解析异常", resultType=RESULT::class.java)
}
} else {
Expand Down

0 comments on commit c04289c

Please sign in to comment.