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

Re-add sync error categories. #6913

Merged
merged 7 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
### Enhancements
* <New feature description> (PR [#????](https://github.com/realm/realm-core/pull/????))
* Added support for server log messages that are enabled by sync protocol version 10. Appservices request id will be provided in a server log message in a future server release. ([PR #6476](https://github.com/realm/realm-core/pull/6476))
* A new `ErrorCategory::sync_error` has been added. All errors related to the Sync client, protocol or session will have this category.
Note that websocket errors will have both the `websocket_error` and `sync_error` category, similar to `app_error` and `http_error`
for failed HTTP requests from the App. ([#6916](https://github.com/realm/realm-core/issues/6916))

### Fixed
* <How do the end-user experience this issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)
Expand Down
26 changes: 19 additions & 7 deletions src/realm/error_codes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ ErrorCategory ErrorCodes::error_categories(Error code)
break;

case AddressSpaceExhausted:
case BadChangeset:
case BadVersion:
case BrokenInvariant:
case CallbackFailed:
Expand All @@ -47,22 +46,30 @@ ErrorCategory ErrorCodes::error_categories(Error code)
case RangeError:
case RuntimeError:
case SchemaVersionMismatch:
case SubscriptionFailed:
case UnsupportedFileFormatVersion:
case OperationAborted:
return ErrorCategory().set(ErrorCategory::runtime_error);

case AutoClientResetFailed:
case BadChangeset:
case ConnectionClosed:
case SubscriptionFailed:
case SyncClientResetRequired:
case SyncCompensatingWrite:
case SyncConnectFailed:
case SyncPermissionDenied:
case SyncProtocolInvariantFailed:
case SyncProtocolNegotiationFailed:
case SyncServerPermissionsChanged:
case SyncUserMismatch:
case TlsHandshakeFailed:
case SyncWriteNotAllowed:
return ErrorCategory().set(ErrorCategory::runtime_error);
return ErrorCategory().set(ErrorCategory::runtime_error).set(ErrorCategory::sync_error);

case SyncConnectFailed:
case SyncProtocolNegotiationFailed:
case TlsHandshakeFailed:
return ErrorCategory()
.set(ErrorCategory::runtime_error)
.set(ErrorCategory::websocket_error)
.set(ErrorCategory::sync_error);

case DecryptionFailed:
case DeleteOnOpenRealm:
Expand Down Expand Up @@ -128,11 +135,16 @@ ErrorCategory ErrorCodes::error_categories(Error code)
case TopLevelObject:
case TypeMismatch:
case UnexpectedPrimaryKey:
return ErrorCategory().set(ErrorCategory::invalid_argument).set(ErrorCategory::logic_error);

case BadSyncPartitionValue:
case InvalidSubscriptionQuery:
case SyncInvalidSchemaChange:
case WrongSyncType:
return ErrorCategory().set(ErrorCategory::invalid_argument).set(ErrorCategory::logic_error);
return ErrorCategory()
.set(ErrorCategory::invalid_argument)
.set(ErrorCategory::logic_error)
.set(ErrorCategory::sync_error);

case CustomError:
return ErrorCategory()
Expand Down
1 change: 1 addition & 0 deletions src/realm/error_codes.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef enum realm_error_category {
RLM_ERR_CAT_HTTP_ERROR = 0x0400,
RLM_ERR_CAT_CUSTOM_ERROR = 0x0800,
RLM_ERR_CAT_WEBSOCKET_ERROR = 0x1000,
RLM_ERR_CAT_SYNC_ERROR = 0x2000,
} realm_error_category_e;

typedef enum realm_errno {
Expand Down
1 change: 1 addition & 0 deletions src/realm/error_codes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct ErrorCategory {
http_error = RLM_ERR_CAT_HTTP_ERROR,
custom_error = RLM_ERR_CAT_CUSTOM_ERROR,
websocket_error = RLM_ERR_CAT_WEBSOCKET_ERROR,
sync_error = RLM_ERR_CAT_SYNC_ERROR,
};
constexpr ErrorCategory() = default;
constexpr bool test(Type cat)
Expand Down