From af30a1b67c22aa54dad4e1a0ee3aacb537c4ab92 Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Thu, 22 Oct 2015 14:14:13 +0200 Subject: 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." --- sway/config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sway/config.c') 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) { while (!feof(file)) { line = read_line(file); line = strip_comments(line); - switch(config_command(line)) { + struct cmd_results *res = config_command(line); + switch(res->status) { case CMD_FAILURE: case CMD_INVALID: - sway_log(L_ERROR, "Error on line '%s'", line); + sway_log(L_ERROR, "Error on line '%s': %s", line, res->error); success = false; break; @@ -270,6 +271,7 @@ bool read_config(FILE *file, bool is_active) { default:; } free(line); + free(res); } if (is_active) { -- cgit v1.2.3