mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
switch to php7, add slack error notification
This commit is contained in:
parent
f63c665b7f
commit
d05fd00f73
2 changed files with 10 additions and 5 deletions
|
@ -2,24 +2,24 @@
|
||||||
|
|
||||||
class Debug
|
class Debug
|
||||||
{
|
{
|
||||||
public static function exceptionToString(Exception $e)
|
public static function exceptionToString(Throwable $e)
|
||||||
{
|
{
|
||||||
return static::getExceptionMessageWithoutTrace($e) . "\n" . static::getFullTrace($e);
|
return static::getExceptionMessageWithoutTrace($e) . "\n" . static::getFullTrace($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getExceptionMessageWithoutTrace(Exception $e)
|
public static function getExceptionMessageWithoutTrace(Throwable $e)
|
||||||
{
|
{
|
||||||
return 'exception \'' . get_class($e) . '\' with message \'' . $e->getMessage() . '\' in ' . $e->getFile() . ':' . $e->getLine();
|
return 'exception \'' . get_class($e) . '\' with message \'' . $e->getMessage() . '\' in ' . $e->getFile() . ':' . $e->getLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as the normal getTraceAsString(), but does not truncate long lines.
|
* Same as the normal getTraceAsString(), but does not truncate long lines.
|
||||||
* @param Exception $exception
|
* @param Throwable $exception
|
||||||
* @return string
|
* @return string
|
||||||
* @see http://stackoverflow.com/questions/1949345/how-can-i-get-the-full-string-of-phps-gettraceasstring/6076667#6076667
|
* @see http://stackoverflow.com/questions/1949345/how-can-i-get-the-full-string-of-phps-gettraceasstring/6076667#6076667
|
||||||
* @see https://gist.github.com/1437966
|
* @see https://gist.github.com/1437966
|
||||||
*/
|
*/
|
||||||
public static function getFullTrace(Exception $exception)
|
public static function getFullTrace(Throwable $exception)
|
||||||
{
|
{
|
||||||
$rtn = '';
|
$rtn = '';
|
||||||
foreach ($exception->getTrace() as $count => $frame)
|
foreach ($exception->getTrace() as $count => $frame)
|
||||||
|
|
|
@ -23,10 +23,15 @@ try
|
||||||
}
|
}
|
||||||
Controller::dispatch(strtok($_SERVER['REQUEST_URI'], '?'));
|
Controller::dispatch(strtok($_SERVER['REQUEST_URI'], '?'));
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Throwable $e)
|
||||||
{
|
{
|
||||||
if (IS_PRODUCTION)
|
if (IS_PRODUCTION)
|
||||||
{
|
{
|
||||||
|
$slackErrorNotificationUrl = Config::get('slack_error_notification_url');
|
||||||
|
if ($slackErrorNotificationUrl)
|
||||||
|
{
|
||||||
|
Curl::post($slackErrorNotificationUrl, ['text' => '<!everyone> ' . $e->__toString()], ['json_data' => true]);
|
||||||
|
}
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue