Skip to content

Remove all force unwraps / force try #22

@stefanomondino

Description

@stefanomondino

After #18 is merged, we should work on SDK safety.

Code is still full of force unwraps (someVar!.something()) and force try (try! something) which is dangerous as it could lead to crashes.

We should remove all of them, apps should not crash because of our SDK.

Fixing strategy should be:

  • if a method is already throwing, simply use try instead of try!. If error is not blocking, use try? and provide a fallback value
  • if a method is not marked as throwing, use try? and provide fallback value with nil coalescing operator (let value = (try? something()) ?? defaultValue)
  • in testSomething methods (Unit tests with XCTest, in Tests folder), simply add throws to method declaration

It's not easy to spot them all, but using Xcode looking glass and searching for try! can be a good start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions