Skip to content

Commit

Permalink
Updated Decoding of Error Details
Browse files Browse the repository at this point in the history
* If they can’t be decoded, the original object is included in the error
* This changes the method’s behavior: Currently, undecodable objects are discarded
  • Loading branch information
yakovmanshin committed Aug 26, 2024
1 parent f7056e9 commit 19ce33f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions FirebaseFunctions/Sources/FunctionsError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ extension FunctionsErrorCode {
description = code.descriptionForErrorCode
}

// Update `details` only if the object can be decoded.
if let innerDetails = errorDetails["details"],
details = errorDetails["details"] as AnyObject?
// Update `details` only if decoding succeeds;
// otherwise, keep the original object.
if let innerDetails = details,
let decodedDetails = try? serializer.decode(innerDetails) {
details = decodedDetails
}
Expand Down

0 comments on commit 19ce33f

Please sign in to comment.