Subsonic API: better parameter/error handling

This commit is contained in:
emeric
2019-04-07 17:23:46 +02:00
parent 9ebea81104
commit b4103999a7
3 changed files with 58 additions and 34 deletions
+19 -2
View File
@@ -66,15 +66,32 @@ ErrorCodeToString(Error::Code error)
}
}
static
const char*
CustomTypeToString(Error::CustomType type)
{
switch (type)
{
case Error::CustomType::BadId:
return "Bad id";
case Error::CustomType::NotImplemented:
return "Not implemented";
case Error::CustomType::InternalError:
return "Internal error";
default:
return "Unknown custom error";
}
}
Error::Error(Code code)
: _code {code},
_message {ErrorCodeToString(code)}
{
}
Error::Error(const std::string& message)
Error::Error(Error::CustomType type)
: _code {Code::Generic},
_message {message}
_message {CustomTypeToString(type)}
{
}