Skip to content

Commit 7f298db

Browse files
authored
feat(core): add responseCode to the ResponseException to ease the debugging in case of error (#217)
1 parent 16a2614 commit 7f298db

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

kotlin-sdk/kotlin/src/main/kotlin/io/logto/sdk/core/exception/ResponseException.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class ResponseException(
44
type: Type,
55
cause: Throwable? = null,
66
) : RuntimeException(type.name, cause) {
7+
var responseCode: Int? = null
78
var responseMessage: String? = null
89
var responseContent: String? = null
910

kotlin-sdk/kotlin/src/main/kotlin/io/logto/sdk/core/http/HttpRequest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ fun makeRequest(
3636
if (!response.isSuccessful) {
3737
completion.onComplete(
3838
ResponseException(ResponseException.Type.REQUEST_FAILED).apply {
39+
responseCode = response.code
3940
responseMessage = response.message
4041
responseContent = response.body?.string()
4142
},
@@ -70,6 +71,7 @@ fun makeRequest(
7071
completion.onComplete(null)
7172
} ?: completion.onComplete(
7273
ResponseException(ResponseException.Type.REQUEST_FAILED).apply {
74+
responseCode = response.code
7375
responseMessage = response.message
7476
responseContent = response.body?.string()
7577
},

0 commit comments

Comments
 (0)