Skip to content

Make it possible to easily compare errors #251

@vdkdamian

Description

@vdkdamian

New Feature / Enhancement Checklist

Current Limitation

Currently it's not really easy to know how to compare errors. It would be nice if there is some example in the Playground.

Feature / Enhancement Description

It will be used as an extension.

Example Use Case

if error.containedInParseError([.objectNotFound, .invalidQuery]) {
      assertionFailure("The query is invalid or the object is not found.")
}

Alternatives / Workarounds

guard let parseError = error as? ParseError else {
      //Do stuff for different error
      return
}

switch parseError.code {
      case .objectNotFound: 
            // Handle object not found
      default:
            // There was a different issue that we don't know how to handle
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions