-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gateway] Separate enum for SP lookup errors (#6413)
Currently, MGS has a `SpCommsError` enum that represents pretty much every error that may occur, including failures to look up a SP's address and communication failures while talking to that SP. This means that almost all of the `ManagementSwitch` and `SingleSp` functions return all of the possible errors of any of those operations. Perhaps more importantly, this means that the *authors* of code that calls these functions cannot easily determine which errors will actually be returned by the functions they're calling. For example, while working on #6354, I had incorrectly believed that the `ManagementSwitch::sp` function, which returns a `SingleSp` for a `SpIdentifier`, could fail if there were transient network issues, and that my code would need to handle this. In fact, it turns out that this function only returns an error if discovery hasn't completed yet, or if the `SpIdentifier` is invalid, both of which are fatal errors (and should all never be returned at the point where my code calls that function). Therefore, this branch refactors the error types a bit to separate a `SpLookupError` from `SpCommsError`, and change the `ManagementSwitch` functions that only return errors if discovery hasn't completed successfully or an `SpIdentifier` is invalid to return a `SpLookupError` instead. The `SpCommsError` has a `Discovery` variant which is produced from a `SpLookupError`, so this is actually a fairly minimal change overall --- functions returning a `SpCommsError` via the `?` operator can continue doing so identically to how they do today. I'd like to merge this before #6354, so that I can use it to clean up some error handling code in that branch.
- Loading branch information
Showing
2 changed files
with
46 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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