Patrick Venture | 2bc23fe | 2018-12-13 10:16:36 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <exception> |
| 4 | #include <string> |
| 5 | |
Patrick Venture | 9b534f0 | 2018-12-13 16:10:02 -0800 | [diff] [blame] | 6 | namespace host_tool |
| 7 | { |
| 8 | |
Patrick Venture | 2bc23fe | 2018-12-13 10:16:36 -0800 | [diff] [blame] | 9 | class ToolException : public std::exception |
| 10 | { |
| 11 | public: |
| 12 | explicit ToolException(const std::string& message) : message(message){}; |
| 13 | |
| 14 | virtual const char* what() const noexcept override |
| 15 | { |
| 16 | return message.c_str(); |
| 17 | } |
| 18 | |
| 19 | private: |
| 20 | std::string message; |
| 21 | }; |
Patrick Venture | 9b534f0 | 2018-12-13 16:10:02 -0800 | [diff] [blame] | 22 | |
Benjamin Fair | e5aafa5 | 2020-06-05 21:04:24 -0700 | [diff] [blame] | 23 | class NotFoundException : public ToolException |
| 24 | { |
| 25 | public: |
| 26 | explicit NotFoundException(const std::string& device) : |
| 27 | ToolException(std::string("Couldn't find " + device)){}; |
| 28 | }; |
| 29 | |
Patrick Venture | 9b534f0 | 2018-12-13 16:10:02 -0800 | [diff] [blame] | 30 | } // namespace host_tool |