@@ -54,11 +54,12 @@ actual class HttpsCallableResult constructor(val js: JsHttpsCallableResult) {
5454
5555}
5656
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)
5858
59- @Suppress(" EXTENSION_SHADOWED_BY_MEMBER" )
6059actual val FirebaseFunctionsException .code: FunctionsExceptionCode get() = code
6160
61+ actual val FirebaseFunctionsException .details: Any? get() = details
62+
6263actual enum class FunctionsExceptionCode {
6364 OK ,
6465 CANCELLED ,
@@ -96,25 +97,25 @@ fun errorToException(e: dynamic) = (e?.code ?: e?.message ?: "")
9697 .lowercase()
9798 .let {
9899 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 )
115116 else -> {
116117 println (" Unknown error code in ${JSON .stringify(e)} " )
117- FirebaseFunctionsException (e, FunctionsExceptionCode .UNKNOWN )
118+ FirebaseFunctionsException (e, FunctionsExceptionCode .UNKNOWN , e.details )
118119 }
119120 }
120121 }
0 commit comments