File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -142,7 +142,16 @@ public class BSONDecoder {
142142 return doc
143143 }
144144 let _decoder = _BSONDecoder ( referencing: . document( document) , options: self . options)
145- return try type. init ( from: _decoder)
145+ do {
146+ return try type. init ( from: _decoder)
147+ } catch let error as BSONErrorProtocol {
148+ throw DecodingError . dataCorrupted (
149+ DecodingError . Context (
150+ codingPath: [ ] ,
151+ debugDescription: " Unable to decode BSON \( error. errorDescription ?? " " ) "
152+ )
153+ )
154+ }
146155 }
147156
148157 /**
@@ -532,7 +541,7 @@ private struct _BSONKeyedDecodingContainer<K: CodingKey>: KeyedDecodingContainer
532541 /// Private helper function to check for a value in self.container. Returns the value stored
533542 /// under `key`, or throws an error if the value is not found.
534543 private func getValue( forKey key: Key ) throws -> BSON {
535- guard let entry = ( try convertingBSONErrors { try self . container. getValue ( for: key. stringValue) } ) else {
544+ guard let entry = try self . container. getValue ( for: key. stringValue) else {
536545 throw DecodingError . keyNotFound (
537546 key,
538547 DecodingError . Context (
You can’t perform that action at this time.
0 commit comments