WP Webhooks / Docs / fswa_glue_error
Action since v1.4.0

fswa_glue_error

Fires when an assigned Code Glue snippet errors during a real dispatch (the delivery itself proceeds with the unmodified payload).

$

/ Signature

do_action( 'fswa_glue_error', $webhook_id, $trigger, $stage, $snippet_id, $error )

/ When it fires

A snippet error never breaks the delivery: the snippet runtime catches every Throwable and the payload falls back unmodified. This hook fires at that moment so you can alert on broken glue; the error is also written to the PHP error log, but only when WP_DEBUG is on. A pre-dispatch snippet that ran cleanly but against a payload shape it did not expect (so it silently did nothing) is reported here the same way, with a notice in $error.

/ Parameters

NameInTypeReqDescription
$webhook_idparamintyesWebhook the snippet is assigned to.
$triggerparamstringyesTrigger being dispatched.
$stageparamstringyes`pre` (payload transform) or `post` (after the response).
$snippet_idparamintyesThe failing snippet’s ID.
$errorparamstringyesThe PHP error message, with the line number when known — or, for a pre-dispatch snippet that no-oped against an unexpected payload shape, the notice explaining why.

/ Examples

Email the site admin when production glue starts failing

add_action( 'fswa_glue_error', function ( $webhook_id, $trigger, $stage, $snippet_id, $error ) {
    wp_mail(
        get_option( 'admin_email' ),
        sprintf( 'Code Glue error on webhook #%d', $webhook_id ),
        sprintf( "Snippet #%d (%s stage, trigger %s) failed:\n\n%s", $snippet_id, $stage, $trigger, $error )
    );
}, 10, 5 );

/ Related

Ready

Your next automation is
one sentence away.

$ wp plugin install flowsystems-webhook-actions --activate