Files

16 lines
492 B
PHP
Raw Permalink Normal View History

2016-08-19 10:56:27 -04:00
<?php
class Slack
{
2018-05-21 11:49:15 -04:00
public static function sendErrorIfProd($e, $alert = true)
2016-08-19 10:56:27 -04:00
{
2018-05-21 11:49:15 -04:00
if ($e instanceof Throwable) {
$e = Debug::exceptionToString($e);
}
2016-08-19 10:56:27 -04:00
2018-05-21 11:49:15 -04:00
$slackErrorNotificationUrl = Config::get(Config::SLACK_ERROR_NOTIFICATION_URL);
if ($slackErrorNotificationUrl) {
Curl::post($slackErrorNotificationUrl, ['text' => ($alert ? '<!channel> ' : '') . Request::getRelativeUri() . "\n" . $e], ['json_data' => true]);
}
2016-08-19 10:56:27 -04:00
}
}