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

realm / realm-core / thomas.goyne_275

09 Apr 2024 03:33AM UTC coverage: 92.608% (+0.5%) from 92.088%
thomas.goyne_275

Pull #7300

Evergreen

tgoyne
Extract some duplicated code in PushClient
Pull Request #7300: Rework sync user handling and metadata storage

102672 of 194970 branches covered (52.66%)

3165 of 3247 new or added lines in 46 files covered. (97.47%)

34 existing lines in 9 files now uncovered.

249420 of 269329 relevant lines covered (92.61%)

45087511.34 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
{
608✔
28
    if (code >= 100 && code < 200) {
608✔
29
        return util::format("%1. Informational: %2", prefix, code);
16✔
30
    }
16✔
31
    else if (code >= 200 && code < 300) {
592✔
32
        return util::format("%1. Success: %2", prefix, code);
×
33
    }
×
34
    else if (code >= 300 && code < 400) {
592✔
35
        return util::format("%1. Redirection: %2", prefix, code);
32✔
36
    }
32✔
37
    else if (code >= 400 && code < 500) {
560✔
38
        return util::format("%1. Client Error: %2", prefix, code);
416✔
39
    }
416✔
40
    else if (code >= 500 && code < 600) {
144✔
41
        return util::format("%1. Server Error: %2", prefix, code);
128✔
42
    }
128✔
43
    return util::format("%1. Unknown HTTP Error: %2", prefix, code);
16✔
44
}
16✔
45
} // anonymous namespace
46

47
const char* httpmethod_to_string(HttpMethod method)
48
{
45,263✔
49
    switch (method) {
45,263✔
50
        case HttpMethod::get:
13,622✔
51
            return "GET";
13,622✔
52
        case HttpMethod::post:
30,961✔
53
            return "POST";
30,961✔
54
        case HttpMethod::patch:
✔
NEW
55
            return "PATCH";
×
56
        case HttpMethod::put:
192✔
57
            return "PUT";
192✔
58
        case HttpMethod::del:
488✔
59
            return "DEL";
488✔
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,402✔
73
    // For these errors, the server_error string is empty
2,697✔
74
    REALM_ASSERT(ErrorCodes::error_categories(ec).test(ErrorCategory::app_error));
5,402✔
75
}
5,402✔
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