Error handling in the constructor of a VMOD object

Carlos Abalde carlos.abalde at gmail.com
Tue Sep 17 11:33:23 UTC 2024


On 9/17/24 12:55, Geoff Simmons wrote:

> On 9/17/24 11:54, Carlos Abalde wrote:
>>
>> I'm looking for advise / best-practices related to VMODs, objects and 
>> their __init() constructors.
>> What's your suggestion to handle errors in the constructor?
> if (failure) {
>     VRT_fail(ctx, "printf-like format %string", args, ...);
>     return;
> }
>
> When VRT_fail() is invoked during the function implementing the 
> constructor, the execution of vcl_init is aborted, and the VCL load 
> fails.

Oh! I've being using 'VRT_fail()' to handle as 503 responses 
unrecoverable VMOD error conditions during normal operation, but I 
didn't know / considered it could be using also for initializations. 
Thanks for the tip!

Best,

-- 
Carlos Abalde
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20240917/aff33d42/attachment.html>


More information about the varnish-dev mailing list