command/all: don't create new Response instance in exception handler
The new Response instance in the `catch` block didn't have the `command` attribute set, so the error response didn't indicate which command had failed, which however is required in the MPD protocol. Closes https://github.com/MusicPlayerDaemon/MPD/issues/628
This commit is contained in:
parent
9bff5f9e36
commit
6c9f9c136b
2
NEWS
2
NEWS
|
@ -6,6 +6,8 @@ ver 0.21.14 (not yet released)
|
||||||
* player
|
* player
|
||||||
- fix crash after song change
|
- fix crash after song change
|
||||||
- fix seek position after restarting the decoder
|
- fix seek position after restarting the decoder
|
||||||
|
* protocol
|
||||||
|
- include command name in error responses
|
||||||
|
|
||||||
ver 0.21.13 (2019/08/06)
|
ver 0.21.13 (2019/08/06)
|
||||||
* input
|
* input
|
||||||
|
|
|
@ -363,7 +363,7 @@ command_checked_lookup(Response &r, unsigned permission,
|
||||||
|
|
||||||
CommandResult
|
CommandResult
|
||||||
command_process(Client &client, unsigned num, char *line) noexcept
|
command_process(Client &client, unsigned num, char *line) noexcept
|
||||||
try {
|
{
|
||||||
Response r(client, num);
|
Response r(client, num);
|
||||||
|
|
||||||
/* get the command name (first word on the line) */
|
/* get the command name (first word on the line) */
|
||||||
|
@ -391,32 +391,33 @@ try {
|
||||||
char *argv[COMMAND_ARGV_MAX];
|
char *argv[COMMAND_ARGV_MAX];
|
||||||
Request args(argv, 0);
|
Request args(argv, 0);
|
||||||
|
|
||||||
/* now parse the arguments (quoted or unquoted) */
|
try {
|
||||||
|
/* now parse the arguments (quoted or unquoted) */
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (args.size == COMMAND_ARGV_MAX) {
|
if (args.size == COMMAND_ARGV_MAX) {
|
||||||
r.Error(ACK_ERROR_ARG, "Too many arguments");
|
r.Error(ACK_ERROR_ARG, "Too many arguments");
|
||||||
return CommandResult::ERROR;
|
return CommandResult::ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *a = tokenizer.NextParam();
|
||||||
|
if (a == nullptr)
|
||||||
|
break;
|
||||||
|
|
||||||
|
argv[args.size++] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *a = tokenizer.NextParam();
|
/* look up and invoke the command handler */
|
||||||
if (a == nullptr)
|
|
||||||
break;
|
|
||||||
|
|
||||||
argv[args.size++] = a;
|
const struct command *cmd =
|
||||||
}
|
command_checked_lookup(r, client.GetPermission(),
|
||||||
|
cmd_name, args);
|
||||||
|
if (cmd == nullptr)
|
||||||
|
return CommandResult::ERROR;
|
||||||
|
|
||||||
/* look up and invoke the command handler */
|
return cmd->handler(client, args, r);
|
||||||
|
} catch (...) {
|
||||||
const struct command *cmd =
|
PrintError(r, std::current_exception());
|
||||||
command_checked_lookup(r, client.GetPermission(),
|
|
||||||
cmd_name, args);
|
|
||||||
if (cmd == nullptr)
|
|
||||||
return CommandResult::ERROR;
|
return CommandResult::ERROR;
|
||||||
|
}
|
||||||
return cmd->handler(client, args, r);
|
|
||||||
} catch (...) {
|
|
||||||
Response r(client, num);
|
|
||||||
PrintError(r, std::current_exception());
|
|
||||||
return CommandResult::ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue