It will be useful to have a base protocol for BSONErrors that can be handled/caught at a global level for some applications. Currently if we want to catch a BSON error we would have to type cast to all the known types of errors. It would turn code that looks like this:
func handle(error: Error) {
if let error = error as? BSONValueNotFound {
...
} else if let error = error as? DeserializationError {
...
} else if let error = error as? UnsupportedDocumentDecoding {
...
}
etc..
}
To code that would look like this:
if let error = error as? BSONError {
...
}
It will be useful to have a base protocol for BSONErrors that can be handled/caught at a global level for some applications. Currently if we want to catch a BSON error we would have to type cast to all the known types of errors. It would turn code that looks like this:
To code that would look like this: