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

feat: use general server errors in teams API

This commit is contained in:
Christy Jacob 2022-02-07 01:00:06 +04:00
parent 3cdccf0024
commit 6d343abcb1
3 changed files with 3 additions and 15 deletions

View file

@ -211,11 +211,6 @@ return [
'description' => 'Team with the requested ID could not be found.',
'code' => 404,
],
Exception::TEAM_DELETION_FAILED => [
'name' => Exception::TEAM_DELETION_FAILED,
'description' => 'Failed to delete team from the database.',
'code' => 500,
],
Exception::TEAM_INVITE_ALREADY_EXISTS => [
'name' => Exception::TEAM_INVITE_ALREADY_EXISTS,
'description' => 'The current user already has an invitation to this team.',
@ -249,11 +244,6 @@ return [
'description' => 'Membership with the requested ID could not be found.',
'code' => 404,
],
Exception::MEMBERSHIP_DELETION_FAILED => [
'name' => Exception::MEMBERSHIP_DELETION_FAILED,
'description' => 'Failed to delete membership from the database.',
'code' => 500,
],
/** Avatars */
Exception::AVATAR_SET_NOT_FOUND => [

View file

@ -232,12 +232,12 @@ App::delete('/v1/teams/:teamId')
// TODO delete all members individually from the user object
foreach ($memberships as $membership) {
if (!$dbForProject->deleteDocument('memberships', $membership->getId())) {
throw new Exception('Failed to remove membership for team from DB', 500, Exception::MEMBERSHIP_DELETION_FAILED);
throw new Exception('Failed to remove membership for team from DB', 500, Exception::GENERAL_SERVER_ERROR);
}
}
if (!$dbForProject->deleteDocument('teams', $teamId)) {
throw new Exception('Failed to remove team from DB', 500, Exception::TEAM_DELETION_FAILED);
throw new Exception('Failed to remove team from DB', 500, Exception::GENERAL_SERVER_ERROR);
}
$deletes
@ -767,7 +767,7 @@ App::delete('/v1/teams/:teamId/memberships/:membershipId')
} catch (AuthorizationException $exception) {
throw new Exception('Unauthorized permissions', 401, Exception::USER_UNAUTHORIZED);
} catch (\Exception $exception) {
throw new Exception('Failed to remove membership from DB', 500, Exception::MEMBERSHIP_DELETION_FAILED);
throw new Exception('Failed to remove membership from DB', 500, Exception::GENERAL_SERVER_ERROR);
}
$memberships = $user->getAttribute('memberships', []);

View file

@ -51,7 +51,6 @@ class Exception extends \Exception
/** Teams */
const TEAM_NOT_FOUND = 'team_not_found';
const TEAM_DELETION_FAILED = 'team_deletion_failed';
const TEAM_INVITE_ALREADY_EXISTS = 'team_invite_already_exists';
const TEAM_INVITE_NOT_FOUND = 'team_invite_not_found';
const TEAM_INVALID_SECRET = 'team_invalid_secret';
@ -60,7 +59,6 @@ class Exception extends \Exception
/** Membership */
const MEMBERSHIP_NOT_FOUND = 'membership_not_found';
const MEMBERSHIP_DELETION_FAILED = 'membership_deletion_failed';
/** Avatars */
const AVATAR_SET_NOT_FOUND = 'avatar_set_not_found';