Skip to content

Conversation

sebaland
Copy link
Contributor

@sebaland sebaland commented Sep 13, 2024

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.

@sebaland sebaland requested review from a team as code owners September 13, 2024 15:44
Copy link

codecov bot commented Sep 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@            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 Coverage Δ
Authenticator 41.69% <100.00%> (-0.51%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

harsh62
harsh62 previously approved these changes Sep 13, 2024
Copy link
Member

@harsh62 harsh62 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sebaland sebaland changed the title feat(Authenticator): Allowing to only override the desired errors when invoking the errorMap functions fix(Authenticator): Allowing to only override the desired errors when invoking the errorMap functions Sep 13, 2024
@sebaland sebaland merged commit 068bd3c into main Sep 13, 2024
4 checks passed
@sebaland sebaland deleted the ruisebas/error_mapping_fix branch September 13, 2024 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants