MasterJ93 / ATProtoKit

A straightforward solution for using the AT Protocol and Bluesky, written in Swift.
https://atprotokit.cjrriley.com/documentation/atprotokit/
MIT License
26 stars 5 forks source link

[Feature Request]: Convert from `Result<Success, Failure> to normal return statements #28

Closed MasterJ93 closed 2 months ago

MasterJ93 commented 2 months ago

Summary

All methods in the project will be converted from using Result<Success, Failure> to using throws and singular return models.

Pain points

Originally, most lexicon methods used Result<Success, Failure> as the return statement. However, there are a couple of issues with this approach. For one, when calling the method, the code can easily get unwieldy, with it potentially creating an ever indented triangle. Another issue deals with the fact that there are exceptions to the rule, where some methods only use throws.

To solve these issues, all methods in ATProtoKit will use a singular returns statement and the throws keyword. This will allow all methods to use the do-catch block, thereby containing all potential errors into one block.

With this change, the following will need to be done as well:

Considered Alternatives

N/A

Is this a breaking change?

Yes

Library Examples

Apple's own APIs use this method over Result<Success, Failure> and as a result, it would make sense to do the same.

Additional Context

Tasks: