162c08e9bSKrzysztof Grobelny #include "errors.hpp" 262c08e9bSKrzysztof Grobelny 362c08e9bSKrzysztof Grobelny #include <system_error> 462c08e9bSKrzysztof Grobelny 562c08e9bSKrzysztof Grobelny namespace errors 662c08e9bSKrzysztof Grobelny { 762c08e9bSKrzysztof Grobelny 862c08e9bSKrzysztof Grobelny using namespace std::literals::string_literals; 962c08e9bSKrzysztof Grobelny InvalidArgument(std::string_view propertyNameArg)1062c08e9bSKrzysztof GrobelnyInvalidArgument::InvalidArgument(std::string_view propertyNameArg) : 1162c08e9bSKrzysztof Grobelny propertyName(propertyNameArg), 12*583ba441SPatrick Williams errWhatDetailed( 13*583ba441SPatrick Williams "Invalid argument was given for property: "s + description()) 1462c08e9bSKrzysztof Grobelny {} 1562c08e9bSKrzysztof Grobelny InvalidArgument(std::string_view propertyNameArg,std::string_view info)1662c08e9bSKrzysztof GrobelnyInvalidArgument::InvalidArgument(std::string_view propertyNameArg, 1762c08e9bSKrzysztof Grobelny std::string_view info) : 1862c08e9bSKrzysztof Grobelny propertyName(propertyNameArg), 1962c08e9bSKrzysztof Grobelny errWhatDetailed( 2062c08e9bSKrzysztof Grobelny ("Invalid argument was given for property: "s + description() + ". "s) 2162c08e9bSKrzysztof Grobelny .append(info)) 2262c08e9bSKrzysztof Grobelny {} 2362c08e9bSKrzysztof Grobelny name() const2462c08e9bSKrzysztof Grobelnyconst char* InvalidArgument::name() const noexcept 2562c08e9bSKrzysztof Grobelny { 2662c08e9bSKrzysztof Grobelny return "org.freedesktop.DBus.Error.InvalidArgs"; 2762c08e9bSKrzysztof Grobelny } 2862c08e9bSKrzysztof Grobelny description() const2962c08e9bSKrzysztof Grobelnyconst char* InvalidArgument::description() const noexcept 3062c08e9bSKrzysztof Grobelny { 3162c08e9bSKrzysztof Grobelny return propertyName.c_str(); 3262c08e9bSKrzysztof Grobelny } 3362c08e9bSKrzysztof Grobelny what() const3462c08e9bSKrzysztof Grobelnyconst char* InvalidArgument::what() const noexcept 3562c08e9bSKrzysztof Grobelny { 3662c08e9bSKrzysztof Grobelny return errWhatDetailed.c_str(); 3762c08e9bSKrzysztof Grobelny } 3862c08e9bSKrzysztof Grobelny get_errno() const3962c08e9bSKrzysztof Grobelnyint InvalidArgument::get_errno() const noexcept 4062c08e9bSKrzysztof Grobelny { 4162c08e9bSKrzysztof Grobelny return static_cast<int>(std::errc::invalid_argument); 4262c08e9bSKrzysztof Grobelny } 4362c08e9bSKrzysztof Grobelny 4462c08e9bSKrzysztof Grobelny } // namespace errors 45