From 8864e54f010465365bb94c32f753c3fb606f1445 Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 31 Mar 2007 07:43:05 +0000 Subject: [PATCH] Improve error message layout and information. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1290 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/lib/libvcl/vcc_compile.c | 20 ++++++++++++++------ varnish-cache/lib/libvcl/vcc_token.c | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/varnish-cache/lib/libvcl/vcc_compile.c b/varnish-cache/lib/libvcl/vcc_compile.c index 6bbfbd5e..6adc8723 100644 --- a/varnish-cache/lib/libvcl/vcc_compile.c +++ b/varnish-cache/lib/libvcl/vcc_compile.c @@ -395,21 +395,20 @@ Consist_Decend(struct tokenlist *tl, struct proc *p, unsigned returns) if (u) { #define VCL_RET_MAC(a, b, c, d) \ if (u & VCL_RET_##b) { \ - vsb_printf(tl->sb, "Illegal return for method\n"); \ + vsb_printf(tl->sb, "Illegal action \"%s\"\n", #a); \ vcc_ErrWhere(tl, p->returnt[d]); \ } #include "vcl_returns.h" #undef VCL_RET_MAC - vsb_printf(tl->sb, "In function\n"); + vsb_printf(tl->sb, "\n...in function \"%.*s\"\n", PF(p->name)); vcc_ErrWhere(tl, p->name); return (1); } p->active = 1; TAILQ_FOREACH(pc, &p->calls, list) { if (Consist_Decend(tl, pc->p, returns)) { - vsb_printf(tl->sb, "\nCalled from\n"); - vcc_ErrWhere(tl, p->name); - vsb_printf(tl->sb, "at\n"); + vsb_printf(tl->sb, "\n...called from \"%.*s\"\n", + PF(p->name)); vcc_ErrWhere(tl, pc->t); return (1); } @@ -434,7 +433,16 @@ Consistency(struct tokenlist *tl) continue; if (Consist_Decend(tl, p, m->returns)) { vsb_printf(tl->sb, - "\nwhich is a %s method\n", m->name); + "\n...which is the \"%s\" method\n", m->name); + vsb_printf(tl->sb, "Legal actions are:"); +#define VCL_RET_MAC(a, b, c, d) \ + if (m->returns & c) \ + vsb_printf(tl->sb, " \"%s\"", #a); +#define VCL_RET_MAC_E(a, b, c, d) VCL_RET_MAC(a, b, c, d) +#include "vcl_returns.h" +#undef VCL_RET_MAC +#undef VCL_RET_MAC_E + vsb_printf(tl->sb, "\n"); return (1); } } diff --git a/varnish-cache/lib/libvcl/vcc_token.c b/varnish-cache/lib/libvcl/vcc_token.c index 5f16d448..ca47c8e2 100644 --- a/varnish-cache/lib/libvcl/vcc_token.c +++ b/varnish-cache/lib/libvcl/vcc_token.c @@ -91,7 +91,7 @@ vcc_ErrWhere(struct tokenlist *tl, struct token *t) } else pos++; } - vsb_printf(tl->sb, "In %s Line %d Pos %d\n", f, lin, pos); + vsb_printf(tl->sb, "(%s Line %d Pos %d)\n", f, lin, pos); x = y = 0; for (p = l; p < e && *p != '\n'; p++) { if (*p == '\t') { -- 2.39.5