Krzysztof Grobelny | 62c08e9 | 2022-09-16 10:28:53 +0200 | [diff] [blame^] | 1 | #include "errors.hpp" |
| 2 | |
| 3 | #include <system_error> |
| 4 | |
| 5 | namespace errors |
| 6 | { |
| 7 | |
| 8 | using namespace std::literals::string_literals; |
| 9 | |
| 10 | InvalidArgument::InvalidArgument(std::string_view propertyNameArg) : |
| 11 | propertyName(propertyNameArg), |
| 12 | errWhatDetailed("Invalid argument was given for property: "s + |
| 13 | description()) |
| 14 | {} |
| 15 | |
| 16 | InvalidArgument::InvalidArgument(std::string_view propertyNameArg, |
| 17 | std::string_view info) : |
| 18 | propertyName(propertyNameArg), |
| 19 | errWhatDetailed( |
| 20 | ("Invalid argument was given for property: "s + description() + ". "s) |
| 21 | .append(info)) |
| 22 | {} |
| 23 | |
| 24 | const char* InvalidArgument::name() const noexcept |
| 25 | { |
| 26 | return "org.freedesktop.DBus.Error.InvalidArgs"; |
| 27 | } |
| 28 | |
| 29 | const char* InvalidArgument::description() const noexcept |
| 30 | { |
| 31 | return propertyName.c_str(); |
| 32 | } |
| 33 | |
| 34 | const char* InvalidArgument::what() const noexcept |
| 35 | { |
| 36 | return errWhatDetailed.c_str(); |
| 37 | } |
| 38 | |
| 39 | int InvalidArgument::get_errno() const noexcept |
| 40 | { |
| 41 | return static_cast<int>(std::errc::invalid_argument); |
| 42 | } |
| 43 | |
| 44 | } // namespace errors |