From 4bd5b96735dc105c8c9adb5255cce75bd722a847 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sat, 18 Jun 2016 06:36:37 +0800 Subject: [PATCH] lejp conf report human readable errors Signed-off-by: Andy Green --- lib/lejp-conf.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/lejp-conf.c b/lib/lejp-conf.c index 1ac84ef1..1d529a1f 100644 --- a/lib/lejp-conf.c +++ b/lib/lejp-conf.c @@ -115,6 +115,33 @@ enum lejp_vhost_paths { LEJPVP_SSL_OPTION_CLEAR, }; +static const char * const parser_errs[] = { + "", + "", + "No opening '{'", + "Expected closing '}'", + "Expected '\"'", + "String underrun", + "Illegal unescaped control char", + "Illegal escape format", + "Illegal hex number", + "Expected ':'", + "Illegal value start", + "Digit required after decimal point", + "Bad number format", + "Bad exponent format", + "Unknown token", + "Too many ']'", + "Mismatched ']'", + "Expected ']'", + "JSON nesting limit exceeded", + "Nesting tracking used up", + "Number too long", + "Comma or block end expected", + "Unknown", + "Parser callback errored (see earlier error)", +}; + #define MAX_PLUGIN_DIRS 10 struct jpargs { @@ -547,7 +574,8 @@ lwsws_get_config(void *user, const char *f, const char * const *paths, lejp_destruct(&ctx); if (m < 0) { - lwsl_err("%s(%u): parsing error %d\n", f, n, m); + lwsl_err("%s(%u): parsing error %d: %s\n", f, n, m, + parser_errs[-m]); return 2; }