Browse Source

fix: 全局取消请求时发生ConvertException错误提示

drake 1 year ago
parent
commit
5a0b71be41
1 changed files with 4 additions and 0 deletions
  1. 4 0
      net/src/main/java/com/drake/net/response/ResponseExtension.kt

+ 4 - 0
net/src/main/java/com/drake/net/response/ResponseExtension.kt

@@ -162,6 +162,8 @@ fun Response.file(): File? {
 inline fun <reified R> Response.convert(): R {
     try {
         return request.converter().onConvert<R>(typeTokenOf<R>(), this) as R
+    } catch (e: CancellationException) {
+        throw e
     } catch (e: NetException) {
         throw e
     } catch (e: Throwable) {
@@ -179,6 +181,8 @@ inline fun <reified R> Response.convert(): R {
 fun <R> Response.convert(type: Type): R {
     try {
         return request.converter().onConvert<R>(type, this) as R
+    } catch (e: CancellationException) {
+        throw e
     } catch (e: NetException) {
         throw e
     } catch (e: Throwable) {