maknz / slack

A simple PHP package for sending messages to Slack, with a focus on ease of use and elegant syntax.
BSD 2-Clause "Simplified" License
1.17k stars 204 forks source link

Success and error callbacks #62

Open helsont opened 8 years ago

helsont commented 8 years ago

This is especially important if an error has occurred, which happens frequently when the correct channel is not specified. Right now the error is just thrown, but an error callback would be a much more graceful way of handling it.

soullivaneuh commented 8 years ago

Could you please provide a concrete use case?

Why a try catch would not be sufficient?

newelement commented 8 years ago

When sending a message fails it's causing laravel queues to fail even when using try catch.

duyemura commented 7 years ago

I'm seeing the same thing - unless I'm implementing incorrectly.

`$settings = [ 'username' => 'XYZ', 'channel' => '#' .$integration['slack_notification_channel'], 'link_names' => true, 'unfurl_links' => true, 'unfurl_media' => true ];

        $slack = new Maknz\Slack\Client('this-isnot-a-valid-webhook-url', $settings);

        $copy = "testing your settings.  If you see this message, everything is good to go!";
            try {
                $test = $slack->send($copy);

            }
            catch (Exception $e) { 
                 echo $e->getMessage();
                die("ERROR");
            }
        }

`

This code will seem to work without throwing an error and catching....