1
0
Fork 0
mirror of synced 2024-06-17 10:14:50 +12:00

feat: use general server errors in functions API

This commit is contained in:
Christy Jacob 2022-02-07 00:53:26 +04:00
parent 8189dba42c
commit 1613b3f79e
3 changed files with 3 additions and 21 deletions

View file

@ -349,11 +349,6 @@ return [
'description' => 'The uploaded file is invalid. Please check the file and try again.',
'statusCode' => 403,
],
Exception::STORAGE_FAILED_TO_MOVE_FILE => [
'name' => Exception::STORAGE_FAILED_TO_MOVE_FILE,
'description' => 'Failed to move the uploaded file.',
'statusCode' => 500,
],
Exception::STORAGE_FAILED_TO_WRITE_FILE => [
'name' => Exception::STORAGE_FAILED_TO_WRITE_FILE,
'description' => 'Failed to save the uploaded file.',
@ -366,11 +361,6 @@ return [
'description' => 'The requested function could not be found.',
'statusCode' => 404,
],
Exception::FUNCTION_DELETION_FAILED => [
'name' => Exception::FUNCTION_DELETION_FAILED,
'description' => 'Failed to delete the function from the database.',
'statusCode' => 500,
],
/** Deployments */
Exception::DEPLOYMENT_NOT_FOUND => [
@ -378,11 +368,6 @@ return [
'description' => 'The requested deployment could not be found.',
'statusCode' => 404,
],
Exception::DEPLOYMENT_DELETION_FAILED => [
'name' => Exception::DEPLOYMENT_DELETION_FAILED,
'description' => 'Failed to delete the deployment from the database.',
'statusCode' => 500,
],
/** Executions */
Exception::EXECUTION_NOT_FOUND => [

View file

@ -420,7 +420,7 @@ App::delete('/v1/functions/:functionId')
}
if (!$dbForProject->deleteDocument('functions', $function->getId())) {
throw new Exception('Failed to remove function from DB', 500, Exception::FUNCTION_DELETION_FAILED);
throw new Exception('Failed to remove function from DB', 500, Exception::GENERAL_SERVER_ERROR);
}
$deletes
@ -496,7 +496,7 @@ App::post('/v1/functions/:functionId/tags')
$path = $device->getPath(\uniqid().'.'.\pathinfo($file['name'], PATHINFO_EXTENSION));
if (!$device->upload($file['tmp_name'], $path)) { // TODO deprecate 'upload' and replace with 'move'
throw new Exception('Failed moving file', 500, Exception::STORAGE_FAILED_TO_MOVE_FILE);
throw new Exception('Failed moving file', 500, Exception::GENERAL_SERVER_ERROR);
}
$tagId = $dbForProject->getId();
@ -654,7 +654,7 @@ App::delete('/v1/functions/:functionId/tags/:tagId')
if ($device->delete($tag->getAttribute('path', ''))) {
if (!$dbForProject->deleteDocument('tags', $tag->getId())) {
throw new Exception('Failed to remove tag from DB', 500, Exception::DEPLOYMENT_DELETION_FAILED);
throw new Exception('Failed to remove tag from DB', 500, Exception::GENERAL_SERVER_ERROR);
}
}

View file

@ -78,16 +78,13 @@ class Exception extends \Exception
const STORAGE_FILE_TYPE_UNSUPPORTED = 'storage_file_type_unsupported';
const STORAGE_INVALID_FILE_SIZE = 'storage_invalid_file_size';
const STORAGE_INVALID_FILE = 'storage_invalid_file';
const STORAGE_FAILED_TO_MOVE_FILE = 'storage_failed_to_move_file';
const STORAGE_FAILED_TO_WRITE_FILE = 'storage_failed_to_write_file';
/** Functions */
const FUNCTION_NOT_FOUND = 'function_not_found';
const FUNCTION_DELETION_FAILED = 'function_deletion_failed';
/** Deployments */
const DEPLOYMENT_NOT_FOUND = 'deployment_not_found';
const DEPLOYMENT_DELETION_FAILED = 'deployment_deletion_failed';
/** Execution */
const EXECUTION_NOT_FOUND = 'execution_not_found';