diff options
author | Max Kellermann <max@duempel.org> | 2016-02-07 01:09:10 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2016-02-07 01:09:10 +0100 |
commit | 6a789b660a40054f24b1f3a8e52fc3e243e69ba2 (patch) | |
tree | addcb4b9beaf1e0b3dfd91b4fd74fa4a453b5f48 | |
parent | 0d8e44a079d5c2e14adf43df42164b597b98f81a (diff) |
command/CommandError: move code to ToAck(DatabaseErrorCode)
-rw-r--r-- | src/command/CommandError.cxx | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/command/CommandError.cxx b/src/command/CommandError.cxx index 6885028b7..c3a726920 100644 --- a/src/command/CommandError.cxx +++ b/src/command/CommandError.cxx @@ -66,6 +66,24 @@ ToAck(PlaylistResult result) return ACK_ERROR_UNKNOWN; } +#ifdef ENABLE_DATABASE +gcc_const +static enum ack +ToAck(DatabaseErrorCode code) +{ + switch (code) { + case DatabaseErrorCode::DISABLED: + case DatabaseErrorCode::NOT_FOUND: + return ACK_ERROR_NO_EXIST; + + case DatabaseErrorCode::CONFLICT: + return ACK_ERROR_ARG; + } + + return ACK_ERROR_UNKNOWN; +} +#endif + CommandResult print_playlist_result(Response &r, PlaylistResult result) { @@ -129,14 +147,7 @@ ToAck(const Error &error) return (enum ack)error.GetCode(); #ifdef ENABLE_DATABASE } else if (error.IsDomain(db_domain)) { - switch ((DatabaseErrorCode)error.GetCode()) { - case DatabaseErrorCode::DISABLED: - case DatabaseErrorCode::NOT_FOUND: - return ACK_ERROR_NO_EXIST; - - case DatabaseErrorCode::CONFLICT: - return ACK_ERROR_ARG; - } + return ToAck((DatabaseErrorCode)error.GetCode()); #endif } else if (error.IsDomain(locate_uri_domain)) { return ACK_ERROR_ARG; |