Shawn McCarney | 8c23245 | 2021-05-05 18:44:57 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2021 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #pragma once |
| 17 | |
| 18 | #include <sdbusplus/exception.hpp> |
| 19 | |
| 20 | #include <string> |
| 21 | |
| 22 | namespace phosphor::power::regulators |
| 23 | { |
| 24 | |
| 25 | /** |
| 26 | * Concrete subclass of sdbusplus::exception_t abstract base class. |
| 27 | */ |
| 28 | class TestSDBusError : public sdbusplus::exception_t |
| 29 | { |
| 30 | public: |
Patrick Williams | 48781ae | 2023-05-10 07:50:50 -0500 | [diff] [blame] | 31 | TestSDBusError(const std::string& error) : error{error} {} |
Shawn McCarney | 8c23245 | 2021-05-05 18:44:57 -0500 | [diff] [blame] | 32 | |
| 33 | const char* what() const noexcept override |
| 34 | { |
| 35 | return error.c_str(); |
| 36 | } |
| 37 | |
| 38 | const char* name() const noexcept override |
| 39 | { |
| 40 | return ""; |
| 41 | } |
| 42 | |
| 43 | const char* description() const noexcept override |
| 44 | { |
| 45 | return ""; |
| 46 | } |
| 47 | |
Patrick Williams | 38f802a | 2021-09-08 15:40:13 -0500 | [diff] [blame] | 48 | int get_errno() const noexcept override |
| 49 | { |
| 50 | return EIO; |
| 51 | } |
| 52 | |
Shawn McCarney | 8c23245 | 2021-05-05 18:44:57 -0500 | [diff] [blame] | 53 | private: |
| 54 | const std::string error{}; |
| 55 | }; |
| 56 | |
| 57 | } // namespace phosphor::power::regulators |