Commit ac4740f2 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Allow a string argument to return(fail("Because!"));

Fixes #2694
parent 931ead58
......@@ -14,9 +14,15 @@ client c1 {
varnish v1 -errvcl {VCL "vcl2" Failed initialization} {
sub vcl_init {
return (fail);
return(fail("Do Not Press This Button Again"));
}
backend b1 { .host = "${s1_addr}"; }
}
varnish v1 -errvcl {Do Not Press} {
sub vcl_init {
return(fail("Do Not Press This Button Again"));
}
backend b1 { .host = "${s1_addr}"; }
}
......
......@@ -217,6 +217,22 @@ vcc_act_return_pass(struct vcc *tl)
}
/*--------------------------------------------------------------------*/
static void
vcc_act_return_fail(struct vcc *tl)
{
ExpectErr(tl, '(');
vcc_NextToken(tl);
Fb(tl, 1, "VRT_fail(ctx,\n");
tl->indent += INDENT;
vcc_Expr(tl, STRING);
tl->indent -= INDENT;
ERRCHK(tl);
SkipToken(tl, ')');
Fb(tl, 1, ");\n");
}
/*--------------------------------------------------------------------*/
static void
vcc_act_return_synth(struct vcc *tl)
{
......@@ -321,6 +337,8 @@ vcc_act_return(struct vcc *tl, struct token *t, struct symbol *sym)
vcc_act_return_vcl(tl);
else if (hand == VCL_RET_PASS)
vcc_act_return_pass(tl);
else if (hand == VCL_RET_FAIL)
vcc_act_return_fail(tl);
else {
VSB_printf(tl->sb, "Arguments not allowed.\n");
vcc_ErrWhere(tl, tl->t);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment