Returning an error (exception) from vmod's function

Mikhail T. mi+thun at
Wed Oct 24 15:33:48 CEST 2012

I can't find an example of a vmod's function indicating an error -- 
other than returning NULL in std.readfile().

Besides normal results, my vmod's functions can fail due to a number of 
reasons and I'd like to be able to, at least, indicate them to the 
caller (vcl_recv) so an intelligent status can be returned to the 
client: some times the error ought to be 403 (my module checks 
credentials), and some times it must be 500 (internal error, an 
exception), for example.

Currently I log such exceptions with syslog(3) and return a static 
string to vcl_recv. But then there is no (easy) way to distinguish the 
kinds of failures...

Is there a proper way to do this? Something like SetStatus(sp, int 
status, const char *format, ...)? Thanks!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the varnish-misc mailing list