helper/command: print the command output in case of error
In case of error, a command should use command_print() to report the error message, so it get printed only on the session that run the command itself, and the message can be intercepted with the tcl command catch if it has to be handled differently. Current code drops the command output when the command returns error, claiming that it's the command that *should* have printed it already. This is true only if we *abuse* of the LOG functions, but accepting the side issue of having the LOG printed in every session and being unable to catch{} the error message. Since we have switched to command_print(), change the code to propagate the command output also in case of error. Change-Id: I95de424a65e63702bdb3b2277749a0ac6aaaa503 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5178 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
parent
e162200ab2
commit
2b78f65aa9
|
@ -623,15 +623,13 @@ static int run_command(struct command_context *context,
|
|||
}
|
||||
} else if (retval == ERROR_COMMAND_CLOSE_CONNECTION) {
|
||||
/* just fall through for a shutdown request */
|
||||
} else if (retval != ERROR_OK) {
|
||||
/* we do not print out an error message because the command *should*
|
||||
* have printed out an error
|
||||
*/
|
||||
char *full_name = command_name(c, ' ');
|
||||
LOG_DEBUG("Command '%s' failed with error code %d",
|
||||
full_name ? full_name : c->name, retval);
|
||||
free(full_name);
|
||||
} else {
|
||||
if (retval != ERROR_OK) {
|
||||
char *full_name = command_name(c, ' ');
|
||||
LOG_DEBUG("Command '%s' failed with error code %d",
|
||||
full_name ? full_name : c->name, retval);
|
||||
free(full_name);
|
||||
}
|
||||
/* Use the command output as the Tcl result */
|
||||
Jim_SetResult(context->interp, cmd.output);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue