Skip to content

Support for a Base BSONError protocol #51

@Andrewangeta

Description

@Andrewangeta

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 {
...
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions