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 | 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 | 6 | m_errorName(std::move(errorName)), m_code(code) {} | |
| 30 | |||
| 31 | 3 | ApiError::~ApiError() = default; | |
| 32 | |||
| 33 | } | ||
| 34 |