chrono_batch_render/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
12 / 12
100.0%
Branches:
3 / 3
100.0%
Functions:
7 / 7
100.0%

util/error.cpp
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 #include "chrono_batch_render/util/error.h"
3
4 #include <fmt/format.h>
5
6 namespace chrono::batch_render {
7 namespace {
8
9 3 std::string ApiMessage(std::string_view call, std::string_view errorName, long code,
10 std::string_view description) {
11
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 time.
3 if (description.empty()) {
12 2 return fmt::format("{} failed: {} ({})", call, errorName, code);
13 }
14 1 return fmt::format("{} failed: {} ({}): {}", call, errorName, code, description);
15 }
16
17 }
18
19 373 Error::Error(const std::string& message) : std::runtime_error(message) {}
20
21 375 Error::~Error() = default;
22
23 79 UnsupportedError::~UnsupportedError() = default;
24
25 1 DeviceLostError::~DeviceLostError() = default;
26
27 3 ApiError::ApiError(std::string call, std::string errorName, long code, std::string_view description)
28 3 : Error(ApiMessage(call, errorName, code, description)), m_call(std::move(call)),
29
1/1
✓ Branch 2 taken 3 times.
6 m_errorName(std::move(errorName)), m_code(code) {}
30
31 3 ApiError::~ApiError() = default;
32
33 }
34