Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services

Home Page:https://seldaek.github.io/monolog/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How should we catch exceptions with the SlackWebhookHandler cURL requests?

toby-griffiths opened this issue · comments

Monolog version 3

We have the SlackWebhookHandler implemented in a Symfony project, but have realised that it does not catch exceptions thrown if the cURL request to Slack fails.

We would like to protect our application from completely falling over in the event of comms with Slack failing.

What do people think about adding some error handling around the cURL request in the SlackWebhookHandler. I appreciate that we could decorate the handler to add this ourselves, but this is one of the few things that doesn't seem to be well documented in the Symfony docs, as to how to implement, and I've spend over an hour trying to work it out.

Keen to know whether this is something people thing we should implement here, or in Symfony?

I've also raised symfony/monolog-bundle#465 to gether thoughts on handling this in Symfony.

There is a WhatFailureGroupHandler that can be used to wrap other handlers and catch their error.

Right, the idea is that either you suppress errors with WhatFailureGroupHandler or by default we let errors fail so that you notice the problem, otherwise misconfigured logging would simply fail to log silently and that gives a false sense that everything is fine.