@@ -54,11 +54,12 @@ actual class HttpsCallableResult constructor(val js: JsHttpsCallableResult) {
54
54
55
55
}
56
56
57
- actual class FirebaseFunctionsException (cause : Throwable , val code : FunctionsExceptionCode ) : FirebaseException(code.toString() , cause)
57
+ actual class FirebaseFunctionsException (cause : Throwable , val code : FunctionsExceptionCode , val details : Any? ) : FirebaseException(cause.message , cause)
58
58
59
- @Suppress(" EXTENSION_SHADOWED_BY_MEMBER" )
60
59
actual val FirebaseFunctionsException .code: FunctionsExceptionCode get() = code
61
60
61
+ actual val FirebaseFunctionsException .details: Any? get() = details
62
+
62
63
actual enum class FunctionsExceptionCode {
63
64
OK ,
64
65
CANCELLED ,
@@ -96,25 +97,25 @@ fun errorToException(e: dynamic) = (e?.code ?: e?.message ?: "")
96
97
.lowercase()
97
98
.let {
98
99
when {
99
- " cancelled" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .CANCELLED )
100
- " invalid-argument" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .INVALID_ARGUMENT )
101
- " deadline-exceeded" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .DEADLINE_EXCEEDED )
102
- " not-found" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .NOT_FOUND )
103
- " already-exists" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .ALREADY_EXISTS )
104
- " permission-denied" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .PERMISSION_DENIED )
105
- " resource-exhausted" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .RESOURCE_EXHAUSTED )
106
- " failed-precondition" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .FAILED_PRECONDITION )
107
- " aborted" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .ABORTED )
108
- " out-of-range" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .OUT_OF_RANGE )
109
- " unimplemented" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .UNIMPLEMENTED )
110
- " internal" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .INTERNAL )
111
- " unavailable" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .UNAVAILABLE )
112
- " data-loss" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .DATA_LOSS )
113
- " unauthenticated" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .UNAUTHENTICATED )
114
- " unknown" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .UNKNOWN )
100
+ " cancelled" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .CANCELLED , e.details )
101
+ " invalid-argument" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .INVALID_ARGUMENT , e.details )
102
+ " deadline-exceeded" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .DEADLINE_EXCEEDED , e.details )
103
+ " not-found" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .NOT_FOUND , e.details )
104
+ " already-exists" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .ALREADY_EXISTS , e.details )
105
+ " permission-denied" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .PERMISSION_DENIED , e.details )
106
+ " resource-exhausted" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .RESOURCE_EXHAUSTED , e.details )
107
+ " failed-precondition" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .FAILED_PRECONDITION , e.details )
108
+ " aborted" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .ABORTED , e.details )
109
+ " out-of-range" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .OUT_OF_RANGE , e.details )
110
+ " unimplemented" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .UNIMPLEMENTED , e.details )
111
+ " internal" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .INTERNAL , e.details )
112
+ " unavailable" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .UNAVAILABLE , e.details )
113
+ " data-loss" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .DATA_LOSS , e.details )
114
+ " unauthenticated" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .UNAUTHENTICATED , e.details )
115
+ " unknown" in it -> FirebaseFunctionsException (e, FunctionsExceptionCode .UNKNOWN , e.details )
115
116
else -> {
116
117
println (" Unknown error code in ${JSON .stringify(e)} " )
117
- FirebaseFunctionsException (e, FunctionsExceptionCode .UNKNOWN )
118
+ FirebaseFunctionsException (e, FunctionsExceptionCode .UNKNOWN , e.details )
118
119
}
119
120
}
120
121
}
0 commit comments