summaryrefslogtreecommitdiffstats
path: root/sway/config.c
diff options
context:
space:
mode:
authorLibravatar S. Christoffer Eliesen <christoffer@eliesen.no>2015-10-22 14:14:13 +0200
committerLibravatar S. Christoffer Eliesen <christoffer@eliesen.no>2015-10-22 23:36:24 +0200
commitaf30a1b67c22aa54dad4e1a0ee3aacb537c4ab92 (patch)
tree013c1860550bb3c190095fd0633c08aca16838d1 /sway/config.c
parentipc: Return correct status in ipc reply. (diff)
downloadsway-af30a1b67c22aa54dad4e1a0ee3aacb537c4ab92.tar.gz
sway-af30a1b67c22aa54dad4e1a0ee3aacb537c4ab92.tar.zst
sway-af30a1b67c22aa54dad4e1a0ee3aacb537c4ab92.zip
ipc,commands,config: Replace cmd_status enum with cmd_results struct.
In i3 the ipc reply will contain a human readable error message, and this patch replicates that behaviour. However, that error message is also useful for logging, which this patch takes advantage of. E.g. instead of logging errors directly in commands.c/checkargs, it is fed back to the caller which eventually ends up logging everything with maximum context available (config.c/read_config). So instead of logging e.g. "Error on line 'exit'" it will now log: "Error on line 'exit': Can't execute from config."
Diffstat (limited to 'sway/config.c')
-rw-r--r--sway/config.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sway/config.c b/sway/config.c
index 67f8284c..7e0b22f9 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -234,10 +234,11 @@ bool read_config(FILE *file, bool is_active) {
234 while (!feof(file)) { 234 while (!feof(file)) {
235 line = read_line(file); 235 line = read_line(file);
236 line = strip_comments(line); 236 line = strip_comments(line);
237 switch(config_command(line)) { 237 struct cmd_results *res = config_command(line);
238 switch(res->status) {
238 case CMD_FAILURE: 239 case CMD_FAILURE:
239 case CMD_INVALID: 240 case CMD_INVALID:
240 sway_log(L_ERROR, "Error on line '%s'", line); 241 sway_log(L_ERROR, "Error on line '%s': %s", line, res->error);
241 success = false; 242 success = false;
242 break; 243 break;
243 244
@@ -270,6 +271,7 @@ bool read_config(FILE *file, bool is_active) {
270 default:; 271 default:;
271 } 272 }
272 free(line); 273 free(line);
274 free(res);
273 } 275 }
274 276
275 if (is_active) { 277 if (is_active) {