aws-amplify / amplify-ui-swift-authenticator

The Amplify UI Authenticator is a component that supports several authentiation flows using Amplify Authentication.
https://ui.docs.amplify.aws/swift/connected-components/authenticator
Apache License 2.0
15 stars 9 forks source link

fix(Authenticator): Allowing to only override the desired errors when invoking the errorMap functions #93

Closed ruisebas closed 2 months ago

ruisebas commented 2 months ago

Description of changes:

This PR allows Authenticator customers to invoke the errorMap(_:) view modifiers without having to provide an AuthenticatorError for every possible AuthError. Instead, they can just provide a new value only for the errors they want to overwrite and return nil for all the rest, in which case the Authenticator will proceed to handle them with their default behaviour.

For example, if a user only wants to override the message for . notAuthorized when a specific condition is met, they can now do something like:

Authenticator { _ in 
    // ....
}
.errorMap { error in
    if case .notAuthorized = error, anotherCondition {
        return .error(message: "A custom message for .notAuthorized")
    }

    return nil
}

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 41.69%. Comparing base (2518b16) to head (ad6b06f). Report is 4 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #93 +/- ## ========================================== - Coverage 42.20% 41.69% -0.51% ========================================== Files 41 41 Lines 1872 1902 +30 ========================================== + Hits 790 793 +3 - Misses 1082 1109 +27 ``` | [Flag](https://app.codecov.io/gh/aws-amplify/amplify-ui-swift-authenticator/pull/93/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-amplify) | Coverage Δ | | |---|---|---| | [Authenticator](https://app.codecov.io/gh/aws-amplify/amplify-ui-swift-authenticator/pull/93/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-amplify) | `41.69% <100.00%> (-0.51%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aws-amplify#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.