feat: use general server errors in functions API
This commit is contained in:
parent
8189dba42c
commit
1613b3f79e
3 changed files with 3 additions and 21 deletions
|
@ -349,11 +349,6 @@ return [
|
||||||
'description' => 'The uploaded file is invalid. Please check the file and try again.',
|
'description' => 'The uploaded file is invalid. Please check the file and try again.',
|
||||||
'statusCode' => 403,
|
'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 => [
|
Exception::STORAGE_FAILED_TO_WRITE_FILE => [
|
||||||
'name' => Exception::STORAGE_FAILED_TO_WRITE_FILE,
|
'name' => Exception::STORAGE_FAILED_TO_WRITE_FILE,
|
||||||
'description' => 'Failed to save the uploaded file.',
|
'description' => 'Failed to save the uploaded file.',
|
||||||
|
@ -366,11 +361,6 @@ return [
|
||||||
'description' => 'The requested function could not be found.',
|
'description' => 'The requested function could not be found.',
|
||||||
'statusCode' => 404,
|
'statusCode' => 404,
|
||||||
],
|
],
|
||||||
Exception::FUNCTION_DELETION_FAILED => [
|
|
||||||
'name' => Exception::FUNCTION_DELETION_FAILED,
|
|
||||||
'description' => 'Failed to delete the function from the database.',
|
|
||||||
'statusCode' => 500,
|
|
||||||
],
|
|
||||||
|
|
||||||
/** Deployments */
|
/** Deployments */
|
||||||
Exception::DEPLOYMENT_NOT_FOUND => [
|
Exception::DEPLOYMENT_NOT_FOUND => [
|
||||||
|
@ -378,11 +368,6 @@ return [
|
||||||
'description' => 'The requested deployment could not be found.',
|
'description' => 'The requested deployment could not be found.',
|
||||||
'statusCode' => 404,
|
'statusCode' => 404,
|
||||||
],
|
],
|
||||||
Exception::DEPLOYMENT_DELETION_FAILED => [
|
|
||||||
'name' => Exception::DEPLOYMENT_DELETION_FAILED,
|
|
||||||
'description' => 'Failed to delete the deployment from the database.',
|
|
||||||
'statusCode' => 500,
|
|
||||||
],
|
|
||||||
|
|
||||||
/** Executions */
|
/** Executions */
|
||||||
Exception::EXECUTION_NOT_FOUND => [
|
Exception::EXECUTION_NOT_FOUND => [
|
||||||
|
|
|
@ -420,7 +420,7 @@ App::delete('/v1/functions/:functionId')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$dbForProject->deleteDocument('functions', $function->getId())) {
|
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
|
$deletes
|
||||||
|
@ -496,7 +496,7 @@ App::post('/v1/functions/:functionId/tags')
|
||||||
$path = $device->getPath(\uniqid().'.'.\pathinfo($file['name'], PATHINFO_EXTENSION));
|
$path = $device->getPath(\uniqid().'.'.\pathinfo($file['name'], PATHINFO_EXTENSION));
|
||||||
|
|
||||||
if (!$device->upload($file['tmp_name'], $path)) { // TODO deprecate 'upload' and replace with 'move'
|
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();
|
$tagId = $dbForProject->getId();
|
||||||
|
@ -654,7 +654,7 @@ App::delete('/v1/functions/:functionId/tags/:tagId')
|
||||||
|
|
||||||
if ($device->delete($tag->getAttribute('path', ''))) {
|
if ($device->delete($tag->getAttribute('path', ''))) {
|
||||||
if (!$dbForProject->deleteDocument('tags', $tag->getId())) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,16 +78,13 @@ class Exception extends \Exception
|
||||||
const STORAGE_FILE_TYPE_UNSUPPORTED = 'storage_file_type_unsupported';
|
const STORAGE_FILE_TYPE_UNSUPPORTED = 'storage_file_type_unsupported';
|
||||||
const STORAGE_INVALID_FILE_SIZE = 'storage_invalid_file_size';
|
const STORAGE_INVALID_FILE_SIZE = 'storage_invalid_file_size';
|
||||||
const STORAGE_INVALID_FILE = 'storage_invalid_file';
|
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';
|
const STORAGE_FAILED_TO_WRITE_FILE = 'storage_failed_to_write_file';
|
||||||
|
|
||||||
/** Functions */
|
/** Functions */
|
||||||
const FUNCTION_NOT_FOUND = 'function_not_found';
|
const FUNCTION_NOT_FOUND = 'function_not_found';
|
||||||
const FUNCTION_DELETION_FAILED = 'function_deletion_failed';
|
|
||||||
|
|
||||||
/** Deployments */
|
/** Deployments */
|
||||||
const DEPLOYMENT_NOT_FOUND = 'deployment_not_found';
|
const DEPLOYMENT_NOT_FOUND = 'deployment_not_found';
|
||||||
const DEPLOYMENT_DELETION_FAILED = 'deployment_deletion_failed';
|
|
||||||
|
|
||||||
/** Execution */
|
/** Execution */
|
||||||
const EXECUTION_NOT_FOUND = 'execution_not_found';
|
const EXECUTION_NOT_FOUND = 'execution_not_found';
|
||||||
|
|
Loading…
Reference in a new issue