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.

The CLI prints an error message that the VCL "Failed initialization", and then the formatted message from VRT_fail() in the next line. That's where you can describe the error.

It's very much like a VCL compile failure in that the VCL doesn't load. The difference being that the CLI returns status 300 for an initialization failure, but 106 for a syntax error.

You might want the return right after VRT_fail(), unless you have to do some resource cleanup first. At any rate, you can discontinue the C function as soon as possible.


HTH,
Geoff
--
** * * UPLEX - Nils Goroll Systemoptimierung

Scheffelstraße 32
22301 Hamburg

Tel +49 40 2880 5731
Mob +49 176 636 90917
Fax +49 40 42949753

http://uplex.de

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
varnish-dev mailing list
varnish-dev@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to