mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-12-23 02:00:17 +00:00
31 lines
793 B
PHP
31 lines
793 B
PHP
<?php
|
|
use Friendica\Core\L10n;
|
|
|
|
$container = $slim->getContainer();
|
|
|
|
// Error handler based off https://stackoverflow.com/a/48135009/757392
|
|
$container['errorHandler'] = function () {
|
|
return function(Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response, Exception $exception)
|
|
{
|
|
$responseCode = 500;
|
|
|
|
if (is_a($exception, 'Friendica\Network\HTTPException')) {
|
|
$responseCode = $exception->httpcode;
|
|
}
|
|
|
|
$errors['message'] = $exception->getMessage();
|
|
|
|
$errors['responseCode'] = $responseCode;
|
|
|
|
return $response
|
|
->withStatus($responseCode)
|
|
->withJson($errors);
|
|
};
|
|
};
|
|
|
|
$container['notFoundHandler'] = function () {
|
|
return function ()
|
|
{
|
|
throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('Method not found'));
|
|
};
|
|
};
|