Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This pull request introduces several significant changes to the codebase, focusing on improving error handling, simplifying result representation, and enhancing the criteria evaluation logic. The most important updates include replacing multiple error classes with a unified
ClientErrorhierarchy, introducing theSwitcherResultclass for consistent result representation, and refactoring the criteria evaluation logic to streamline decision-making processes.Error Handling Improvements:
AuthError,CriteriaError,SnapshotServiceError, etc.) with a unifiedClientErrorhierarchy for better consistency and maintainability. (src/lib/exceptions/index.js, [1] [2] [3] [4] [5] [6]errorHandlerfunction to centralize error handling logic and ensure non-ClientErrorinstances are wrapped inRemoteError. (src/lib/remote.js, src/lib/remote.jsL174-R183)Result Representation Enhancements:
SwitcherResultclass to encapsulate the result, reason, and metadata of criteria evaluations, replacing ad-hoc result objects. (src/lib/result.js, src/lib/result.jsR1-R64)SwitcherResultinstances instead of plain objects, improving consistency across the codebase. (src/lib/bypasser/key.js, [1];src/switcher.js, [2]Criteria Evaluation Refactoring:
resolveCriteria,checkGroup, and related methods to simplify decision-making and leverageSwitcherResultfor result representation. (src/lib/resolver.js, [1] [2]checkStrategyConfigandisStrategyFulfilledfor better modularity. (src/lib/resolver.js, src/lib/resolver.jsR4-R135)Miscellaneous Changes:
tests/helper/utils.js, [1] [2]tests/snapshot/default_disabled.json, tests/snapshot/default_disabled.jsonR1-R10)These changes collectively enhance the codebase's maintainability, readability, and robustness while simplifying error handling and result evaluation.