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:
All lines of code with return .success() and return .failure() will be converted into return [success] and return [error] respectively.
In the documentation, the "Returns" section will describe what the method will actually return.
A "Throws" section will be added, directing developers to read more about the ATProtoError-conforming types for more information.
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:
Convert all of the methods to have the singular returns statement.
[x] ATProtoKit
[x] ATProtoBlueskyChat
[x] ATProtocolConfiguration
[x] ATProtoTools
[x] ATProtoAdmin
[x] ATProtoBluesky
[x] Any additional methods unrelated to the above classes.
[x] Update README with updated examples of using ATProtoKit.
[x] Update the "Getting Started with ATProtoKit" article with updated code.
[x] Update the main documentation with updated code.
Summary
All methods in the project will be converted from using
Result<Success, Failure>
to usingthrows
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 usethrows
.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 thedo-catch
block, thereby containing all potential errors into one block.With this change, the following will need to be done as well:
return .success()
andreturn .failure()
will be converted intoreturn [success]
andreturn [error]
respectively.ATProtoError
-conforming types for more information.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:
Convert all of the methods to have the singular returns statement.
[x] ATProtoKit
[x] ATProtoBlueskyChat
[x] ATProtocolConfiguration
[x] ATProtoTools
[x] ATProtoAdmin
[x] ATProtoBluesky
[x] Any additional methods unrelated to the above classes.
[x] Update README with updated examples of using ATProtoKit.
[x] Update the "Getting Started with ATProtoKit" article with updated code.
[x] Update the main documentation with updated code.