- /* We parse the JSON reply to figure out whether there was an error
- * ("success" being false in on of the returned dictionaries). */
- const unsigned char *reply;
-#if YAJL_MAJOR >= 2
- size_t length;
- yajl_handle handle = yajl_alloc(&command_error_callbacks, NULL, NULL);
-#else
- unsigned int length;
- yajl_parser_config parse_conf = { 0, 0 };
-
- yajl_handle handle = yajl_alloc(&command_error_callbacks, &parse_conf, NULL, NULL);
-#endif
- yajl_gen_get_buf(command_output->json_gen, &reply, &length);
-
- current_nesting_level = 0;
- parse_error_key = false;
- command_failed = false;
- yajl_status state = yajl_parse(handle, reply, length);
- if (state != yajl_status_ok) {
- ELOG("Could not parse my own reply. That's weird. reply is %.*s\n", (int)length, reply);
- } else {
- if (command_failed) {
- char *pageraction;
- sasprintf(&pageraction, "i3-sensible-pager \"%s\"\n", errorfilename);
- char *argv[] = {
- NULL, /* will be replaced by the executable path */
- "-t",
- "error",
- "-m",
- "The configured command for this shortcut could not be run successfully.",
- "-b",
- "show errors",
- pageraction,
- NULL
- };
- start_nagbar(&command_error_nagbar_pid, argv);
- free(pageraction);
- }
- }
-
- yajl_free(handle);
-
- yajl_gen_free(command_output->json_gen);