Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SyncError/SessionErrorInfo Status-aware #6824

Merged
merged 6 commits into from
Jul 27, 2023

Conversation

jbreams
Copy link
Contributor

@jbreams jbreams commented Jul 24, 2023

What, How & Why?

This is a transitional PR to make SyncError and sync::SessionErrorInfo aware of Status and use it instead of std::error_code to capture error information. Just in this PR all the actual errors are still std::error_code via the SystemError type, but this change lets me start to transition our various error types without having to change all our tests/call sites at once.

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)
  • C-API, if public C++ API changed.

@jbreams jbreams marked this pull request as ready for review July 26, 2023 02:26
@@ -1111,16 +1112,21 @@ void Connection::close_due_to_protocol_error(std::error_code ec, std::optional<s
void Connection::close_due_to_client_side_error(std::error_code ec, std::optional<std::string_view> msg,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this (std::error_code) will be removed/addressed in later PR's

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I'm just trying to do this in stages.

Copy link
Contributor

@michael-wb michael-wb left a comment

Choose a reason for hiding this comment

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

LGTM - just a few comments.

: ProtocolErrorInfo(ec.value(), msg, try_again)
, error_code(ec)

SessionErrorInfo(Status status, bool try_again)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a Status&& or was this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's both unintentional and does not need to be changed? I haven't verified that all these call sites pass by r-value but Status's are cheap to copy anyways?

enum class ClientResetModeAllowed { DoNotClientReset, RecoveryPermitted, RecoveryNotPermitted };

Status status;
Copy link
Contributor

Choose a reason for hiding this comment

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

Status should probably be a const, since there are two string_views that depend on its contents.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making this const makes SyncError non-assignable - i.e. you can't do something like SyncError copy = other_sync_error or std::optional<SyncError> maybe_sync_error; maybe_sync_error = sync_error; I'm not sure adding that restriction to this type is worth it compared to say a comment saying not to move out the Status if you intend to re-use the SyncError?

Copy link
Contributor

Choose a reason for hiding this comment

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

Understood - the side effects of const are not worth the extra headaches... and a const status() accessor is less efficient.
A comment would probably be good, since one may not notice the string_view references without looking into the class implementation.

@jbreams jbreams merged commit ef215f6 into feature/sync_error_unification Jul 27, 2023
2 checks passed
@jbreams jbreams deleted the jbr/sync_error_to_status branch July 27, 2023 20:10
jbreams added a commit that referenced this pull request Aug 11, 2023
* Add new ErrorCodes for sync error unification (#6829)

* Make SyncError/SessionErrorInfo Status-aware (#6824)

* Replace ClientError error_code with ErrorCodes/Status (#6846)

* Handle websocket errors entirely within sync client (#6859)

* Unify remaining std::error_codes into Status/ErrorCodes in sync client (#6869)

* fix changelog merge with master
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants