| 1 | // Copyright (C) Microsoft Corporation. All rights reserved. |
| 2 | #include <stdexcept> |
| 3 | #include <optional> |
| 4 | #include <source_location> |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | class RuntimeErrorWithSourceLocation : public std::runtime_error |
| 9 | { |
| 10 | public: |
| 11 | RuntimeErrorWithSourceLocation(const std::string& reason, const std::source_location& location = std::source_location::current()); |
| 12 | |
| 13 | RuntimeErrorWithSourceLocation( |
| 14 | const std::string& reason, const std::exception& inner, const std::source_location& location = std::source_location::current()); |
| 15 | |
| 16 | private: |
| 17 | static std::string BuildMessage(const std::string& reason, const std::optional<std::exception>& inner, const std::source_location& location); |
| 18 | }; |