Merge pull request #1515 from Airblader/feature-commands-error-messages
Improve error messages on failing commands
This commit is contained in:
commit
1b69ddacbe
@ -27,16 +27,19 @@
|
|||||||
y(map_close); \
|
y(map_close); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define yerror(message) \
|
#define yerror(format, ...) \
|
||||||
do { \
|
do { \
|
||||||
if (cmd_output->json_gen != NULL) { \
|
if (cmd_output->json_gen != NULL) { \
|
||||||
y(map_open); \
|
char *message; \
|
||||||
ystr("success"); \
|
sasprintf(&message, format, ##__VA_ARGS__); \
|
||||||
y(bool, false); \
|
y(map_open); \
|
||||||
ystr("error"); \
|
ystr("success"); \
|
||||||
ystr(message); \
|
y(bool, false); \
|
||||||
y(map_close); \
|
ystr("error"); \
|
||||||
} \
|
ystr(message); \
|
||||||
|
y(map_close); \
|
||||||
|
free(message); \
|
||||||
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/** When the command did not include match criteria (!), we use the currently
|
/** When the command did not include match criteria (!), we use the currently
|
||||||
@ -574,8 +577,7 @@ void cmd_move_con_to_workspace_number(I3_CMD, char *which) {
|
|||||||
|
|
||||||
if (parsed_num == -1) {
|
if (parsed_num == -1) {
|
||||||
LOG("Could not parse initial part of \"%s\" as a number.\n", which);
|
LOG("Could not parse initial part of \"%s\" as a number.\n", which);
|
||||||
// TODO: better error message
|
yerror("Could not parse number \"%s\"", which);
|
||||||
yerror("Could not parse number");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1007,8 +1009,7 @@ void cmd_workspace_number(I3_CMD, char *which) {
|
|||||||
|
|
||||||
if (parsed_num == -1) {
|
if (parsed_num == -1) {
|
||||||
LOG("Could not parse initial part of \"%s\" as a number.\n", which);
|
LOG("Could not parse initial part of \"%s\" as a number.\n", which);
|
||||||
// TODO: better error message
|
yerror("Could not parse number \"%s\"", which);
|
||||||
yerror("Could not parse number");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2007,10 +2008,7 @@ void cmd_rename_workspace(I3_CMD, char *old_name, char *new_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!workspace) {
|
if (!workspace) {
|
||||||
// TODO: we should include the old workspace name here and use yajl for
|
yerror("Old workspace \"%s\" not found", old_name);
|
||||||
// generating the reply.
|
|
||||||
// TODO: better error message
|
|
||||||
yerror("Old workspace not found");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2020,10 +2018,7 @@ void cmd_rename_workspace(I3_CMD, char *old_name, char *new_name) {
|
|||||||
!strcasecmp(child->name, new_name));
|
!strcasecmp(child->name, new_name));
|
||||||
|
|
||||||
if (check_dest != NULL) {
|
if (check_dest != NULL) {
|
||||||
// TODO: we should include the new workspace name here and use yajl for
|
yerror("New workspace \"%s\" already exists", new_name);
|
||||||
// generating the reply.
|
|
||||||
// TODO: better error message
|
|
||||||
yerror("New workspace already exists");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user