Improved error handling so that Request exceptions and unhandled exceptions are logged using LogLib

This commit is contained in:
netkas 2025-06-06 15:04:16 -04:00
parent 9d17190609
commit 1eb68dcd8d
Signed by: netkas
GPG key ID: 4D8629441B76E4CC

View file

@ -2,7 +2,9 @@
namespace FederationServer;
use Exception;
use FederationServer\Classes\Enums\Method;
use FederationServer\Classes\Logger;
use FederationServer\Classes\RequestHandler;
use FederationServer\Exceptions\RequestException;
use FederationServer\Objects\OperatorRecord;
@ -24,7 +26,6 @@
parent::handleRequest();
// Execute the request method
$requestMethod = Method::matchHandle(self::getRequestMethod(), self::getPath());
if($requestMethod === null)
{
@ -36,8 +37,14 @@
}
catch (RequestException $e)
{
Logger::log()->error('Request Error: ' . $e->getMessage(), $e);
self::throwableResponse($e);
}
catch(Exception $e)
{
Logger::log()->error('Uncaught Exception:' . $e->getMessage(), $e);
self::errorResponse('Internal Server Error');
}
}
/**