summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-11-28 16:29:41 -0800
committerZachary T Welch <zw@superlucidity.net>2009-11-30 20:54:40 -0800
commit330733eadf76ea87ee8714ed7958f174b1be21db (patch)
treec40405503a582cb09d4035af8bbe3e0188c351d9 /src
parent892604bc7e6b332cf3b0bf6c2586cbd0f54ec8ef (diff)
downloadopenocd+libswd-330733eadf76ea87ee8714ed7958f174b1be21db.tar.gz
openocd+libswd-330733eadf76ea87ee8714ed7958f174b1be21db.tar.bz2
openocd+libswd-330733eadf76ea87ee8714ed7958f174b1be21db.tar.xz
openocd+libswd-330733eadf76ea87ee8714ed7958f174b1be21db.zip
improve command prohibition error report
Ensures that the correct information gets displayed, depending on the mode of the command being denied. Fixes misreporting all commands as needing to run "before 'init'".
Diffstat (limited to 'src')
-rw-r--r--src/helper/command.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/helper/command.c b/src/helper/command.c
index 9b9c5ec0..dcad6a19 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -565,8 +565,16 @@ static int run_command(struct command_context *context,
{
if (!command_can_run(context, c))
{
- /* Config commands can not run after the config stage */
- LOG_ERROR("The '%s' command must be used before 'init'.", c->name);
+ /* Many commands may be run only before/after 'init' */
+ const char *when;
+ switch (c->mode) {
+ case COMMAND_CONFIG: when = "before"; break;
+ case COMMAND_EXEC: when = "after"; break;
+ // handle the impossible with humor; it guarantees a bug report!
+ default: when = "if Cthulhu is summoned by"; break;
+ }
+ LOG_ERROR("The '%s' command must be used %s 'init'.",
+ c->name, when);
return ERROR_FAIL;
}