1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00

feat: print correct error messages

This commit is contained in:
Christy Jacob 2022-03-01 18:19:47 +04:00
parent f37bc46abf
commit 1490b7353c
2 changed files with 17 additions and 17 deletions

View file

@ -999,6 +999,7 @@ App::get('/v1/functions/:functionId/executions')
$function = Authorization::skip(fn() => $dbForProject->getDocument('functions', $functionId));
throw new Exception('Function not found', 404, Exception::FUNCTION_NOT_FOUND);
if ($function->isEmpty()) {
throw new Exception('Function not found', 404, Exception::FUNCTION_NOT_FOUND);
}

View file

@ -376,7 +376,20 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project, $l
throw $error;
}
if (php_sapi_name() === 'cli') {
Console::error('[Error] Timestamp: '.date('c', time()));
if($route) {
Console::error('[Error] Method: '.$route->getMethod());
Console::error('[Error] URL: '.$route->getPath());
}
Console::error('[Error] Type: '.get_class($error));
Console::error('[Error] Message: '.$error->getMessage());
Console::error('[Error] File: '.$error->getFile());
Console::error('[Error] Line: '.$error->getLine());
}
/** Handle Utopia Errors */
if ($error instanceof Utopia\Exception) {
$code = $error->getCode();
@ -396,22 +409,6 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project, $l
$error = new Exception($error->getMessage(), $error->getCode(), Exception::GENERAL_UNKNOWN, $error);
}
$template = ($route) ? $route->getLabel('error', null) : null;
if (php_sapi_name() === 'cli') {
Console::error('[Error] Timestamp: '.date('c', time()));
if($route) {
Console::error('[Error] Method: '.$route->getMethod());
Console::error('[Error] URL: '.$route->getPath());
}
Console::error('[Error] Type: '.get_class($error));
Console::error('[Error] Message: '.$error->getMessage());
Console::error('[Error] File: '.$error->getFile());
Console::error('[Error] Line: '.$error->getLine());
}
switch ($error->getCode()) { // Don't show 500 errors!
case 400: // Error allowed publicly
case 401: // Error allowed publicly
@ -456,6 +453,8 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project, $l
->setStatusCode($code)
;
$template = ($route) ? $route->getLabel('error', null) : null;
if ($template) {
$comp = new View($template);