blob: 1937e2d76e95d97c39ab736a95a821884df45401 [file] [log] [blame]
Shawn McCarney8c232452021-05-05 18:44:57 -05001/**
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
22namespace phosphor::power::regulators
23{
24
25/**
26 * Concrete subclass of sdbusplus::exception_t abstract base class.
27 */
28class TestSDBusError : public sdbusplus::exception_t
29{
30 public:
31 TestSDBusError(const std::string& error) : error{error}
Adriana Kobylak0c9a33d2021-09-13 18:05:09 +000032 {}
Shawn McCarney8c232452021-05-05 18:44:57 -050033
34 const char* what() const noexcept override
35 {
36 return error.c_str();
37 }
38
39 const char* name() const noexcept override
40 {
41 return "";
42 }
43
44 const char* description() const noexcept override
45 {
46 return "";
47 }
48
Patrick Williams38f802a2021-09-08 15:40:13 -050049 int get_errno() const noexcept override
50 {
51 return EIO;
52 }
53
Shawn McCarney8c232452021-05-05 18:44:57 -050054 private:
55 const std::string error{};
56};
57
58} // namespace phosphor::power::regulators