• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

realm / realm-core / 2210

09 Apr 2024 03:41PM UTC coverage: 92.601% (+0.5%) from 92.106%
2210

push

Evergreen

web-flow
Merge pull request #7300 from realm/tg/rework-metadata-storage

Rework sync user handling and metadata storage

102800 of 195548 branches covered (52.57%)

3051 of 3153 new or added lines in 46 files covered. (96.76%)

41 existing lines in 11 files now uncovered.

249129 of 269035 relevant lines covered (92.6%)

46864217.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/src/realm/object-store/sync/generic_network_transport.cpp
1
////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2020 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 utilied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
//
17
////////////////////////////////////////////////////////////////////////////
18

19
#include <realm/object-store/sync/generic_network_transport.hpp>
20

21
#include <ostream>
22

23
namespace realm::app {
24

25
namespace {
26
std::string http_message(const std::string& prefix, int code)
27
{
646✔
28
    if (code >= 100 && code < 200) {
646✔
29
        return util::format("%1. Informational: %2", prefix, code);
17✔
30
    }
17✔
31
    else if (code >= 200 && code < 300) {
629✔
32
        return util::format("%1. Success: %2", prefix, code);
×
33
    }
×
34
    else if (code >= 300 && code < 400) {
629✔
35
        return util::format("%1. Redirection: %2", prefix, code);
34✔
36
    }
34✔
37
    else if (code >= 400 && code < 500) {
595✔
38
        return util::format("%1. Client Error: %2", prefix, code);
442✔
39
    }
442✔
40
    else if (code >= 500 && code < 600) {
153✔
41
        return util::format("%1. Server Error: %2", prefix, code);
136✔
42
    }
136✔
43
    return util::format("%1. Unknown HTTP Error: %2", prefix, code);
17✔
44
}
17✔
45
} // anonymous namespace
46

47
const char* httpmethod_to_string(HttpMethod method)
48
{
42,217✔
49
    switch (method) {
42,217✔
50
        case HttpMethod::get:
12,483✔
51
            return "GET";
12,483✔
52
        case HttpMethod::post:
29,015✔
53
            return "POST";
29,015✔
54
        case HttpMethod::patch:
✔
NEW
55
            return "PATCH";
×
56
        case HttpMethod::put:
204✔
57
            return "PUT";
204✔
58
        case HttpMethod::del:
515✔
59
            return "DEL";
515✔
60
    }
×
NEW
61
    return "UNKNOWN";
×
62
}
×
63

64
AppError::AppError(ErrorCodes::Error ec, std::string message, std::string link,
65
                   std::optional<int> additional_error_code, std::optional<std::string> server_err)
66
    : Exception(ec, ec == ErrorCodes::HTTPError && additional_error_code
67
                        ? http_message(message, *additional_error_code)
68
                        : message)
69
    , additional_status_code(additional_error_code)
70
    , link_to_server_logs(link)
71
    , server_error(server_err ? *server_err : "")
72
{
5,730✔
73
    // For these errors, the server_error string is empty
2,688✔
74
    REALM_ASSERT(ErrorCodes::error_categories(ec).test(ErrorCategory::app_error));
5,730✔
75
}
5,730✔
76

77
std::ostream& operator<<(std::ostream& os, AppError error)
78
{
×
79
    return os << error.server_error << ": " << error.what();
×
80
}
×
81

82
} // namespace realm::app
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc