Skip to content

Commit e70e874

Browse files
fix: improve error checking on errorBody decoding
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 4aed1d2 commit e70e874

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

features/exploredash/src/main/java/org/dash/wallet/features/exploredash/repository/CTXSpendRepository.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,15 @@ class CTXSpendException(
4747

4848
init {
4949
val type = object : TypeToken<Map<String, Any>>() {}.type
50-
errorMap = Gson().fromJson(errorBody, type)
50+
errorMap = try {
51+
if (errorBody != null) {
52+
Gson().fromJson(errorBody, type) ?: emptyMap()
53+
} else {
54+
emptyMap()
55+
}
56+
} catch (e: Exception) {
57+
emptyMap()
58+
}
5159
}
5260

5361
val isLimitError

0 commit comments

Comments
 (0)