From 6a789b660a40054f24b1f3a8e52fc3e243e69ba2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 7 Feb 2016 01:09:10 +0100 Subject: [PATCH] command/CommandError: move code to ToAck(DatabaseErrorCode) --- src/command/CommandError.cxx | 27 +++++++++++++++++++-------- 1 file 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;