Closed hackerwins closed 2 months ago
The changes introduce major updates to error handling and mapping across several files in the connecthelper
and converter
packages to better handle connect.Error
and enhance error reporting. Additionally, conditional checks were added in the WatchDocument
method to ensure proper control flow before performing document operations.
Files | Summary |
---|---|
api/converter/errors.go |
Introduced ErrorCodeOf function to extract the error code from a given error, specifically handling connect.Error . |
server/rpc/.../status.go |
Extensive updates to error handling and mapping logic, introducing new functions such as CodeOf , errorToConnectError , and structErrorToConnectError , and modifying ToStatusError to map errors to connectRPC codes. |
server/rpc/testcases/testcases.go |
Added imports and new assertions using functions from connecthelper and converter for better error code comparisons in various test functions. |
server/rpc/yorkie_server.go |
Added a conditional check in the WatchDocument method to handle errors before finding active client information, affecting control flow. |
sequenceDiagram
participant Client
participant YorkieServer
participant Document
Client->>YorkieServer: WatchDocument()
YorkieServer->>YorkieServer: Check conditions
alt Conditions met
YorkieServer->>Document: Find active client info
Document-->>YorkieServer: Return info
YorkieServer-->>Client: Proceed with operations
else Conditions not met
YorkieServer-->>Client: Return error
end
In code's deep forest, changes profound, Errors mapped, new paths found. π² Connect's whispers, softly they speak, Ensuring flows, robust and sleek. Document watches, guarded with care, All in sync, a code we share. π
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Attention: Patch coverage is 15.78947%
with 16 lines
in your changes missing coverage. Please review.
Project coverage is 50.80%. Comparing base (
28ef053
) to head (e76b42d
). Report is 1 commits behind head on main.
Files | Patch % | Lines |
---|---|---|
api/converter/errors.go | 0.00% | 13 Missing :warning: |
server/rpc/yorkie_server.go | 50.00% | 2 Missing and 1 partial :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
What this PR does / why we need it:
Provide error codes for enhancing error handling from clients
Previously, server sends
connect.Code
to clients to indicate error code, such asFailedPrecondition
, in a simplistic manner. This makes it challenging for clients to differentiate and handle individual situations effectively.This commit provides error detailed codes as metadata for enhancing error handling from clients.
Which issue(s) this PR fixes:
Addresses #922
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation:
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Refactor