Realm C++ SDK Version v2.0.1

sync_error.hpp

1
2//
3// Copyright 2024 Realm Inc.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
18
19#ifndef CPPREALM_BRIDGE_SYNC_ERROR_HPP
20#define CPPREALM_BRIDGE_SYNC_ERROR_HPP
21
22#include <cpprealm/internal/bridge/mixed.hpp>
23#include <cpprealm/internal/bridge/status.hpp>
24#include <cpprealm/internal/bridge/utils.hpp>
25
26#include <unordered_map>
27
28namespace realm {
29 struct SyncError;
30}
31
32namespace realm::internal::bridge {
33
35 std::string object_name;
37 std::string reason;
38 };
39
40 struct sync_error {
41 sync_error(const sync_error& other) ;
42 sync_error& operator=(const sync_error& other) ;
43 sync_error(sync_error&& other);
44 sync_error& operator=(sync_error&& other);
46 sync_error(SyncError&&);
47
51 [[nodiscard]] std::unordered_map<std::string, std::string> user_info() const;
54 [[nodiscard]] std::vector<compensating_write_error_info> compensating_writes_info() const;
55
56 [[nodiscard]] status get_status() const;
57
58 [[nodiscard]] bool is_fatal() const;
60 [[nodiscard]] std::string_view message() const;
62 [[nodiscard]] bool is_client_reset_requested() const;
63 private:
64#ifdef CPPREALM_HAVE_GENERATED_BRIDGE_TYPES
65 storage::SyncError m_error[1];
66#else
67 std::shared_ptr<SyncError> m_error;
68#endif
69 };
70}
71
72#endif //CPPREALM_BRIDGE_SYNC_ERROR_HPP
Definition: mixed.hpp:69
Definition: status.hpp:63
Definition: sync_error.hpp:40
std::unordered_map< std::string, std::string > user_info() const
Definition: sync_error.cpp:83
bool is_client_reset_requested() const
The error indicates a client reset situation.
Definition: sync_error.cpp:59
std::string_view message() const
A consolidated explanation of the error, including a link to the server logs if applicable.
Definition: sync_error.cpp:51
std::vector< compensating_write_error_info > compensating_writes_info() const
Definition: sync_error.cpp:91
Definition: managed_primary_key.hpp:30