feat: use general server errors in teams API
This commit is contained in:
parent
3cdccf0024
commit
6d343abcb1
|
@ -211,11 +211,6 @@ return [
|
||||||
'description' => 'Team with the requested ID could not be found.',
|
'description' => 'Team with the requested ID could not be found.',
|
||||||
'code' => 404,
|
'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 => [
|
Exception::TEAM_INVITE_ALREADY_EXISTS => [
|
||||||
'name' => Exception::TEAM_INVITE_ALREADY_EXISTS,
|
'name' => Exception::TEAM_INVITE_ALREADY_EXISTS,
|
||||||
'description' => 'The current user already has an invitation to this team.',
|
'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.',
|
'description' => 'Membership with the requested ID could not be found.',
|
||||||
'code' => 404,
|
'code' => 404,
|
||||||
],
|
],
|
||||||
Exception::MEMBERSHIP_DELETION_FAILED => [
|
|
||||||
'name' => Exception::MEMBERSHIP_DELETION_FAILED,
|
|
||||||
'description' => 'Failed to delete membership from the database.',
|
|
||||||
'code' => 500,
|
|
||||||
],
|
|
||||||
|
|
||||||
/** Avatars */
|
/** Avatars */
|
||||||
Exception::AVATAR_SET_NOT_FOUND => [
|
Exception::AVATAR_SET_NOT_FOUND => [
|
||||||
|
|
|
@ -232,12 +232,12 @@ App::delete('/v1/teams/:teamId')
|
||||||
// TODO delete all members individually from the user object
|
// TODO delete all members individually from the user object
|
||||||
foreach ($memberships as $membership) {
|
foreach ($memberships as $membership) {
|
||||||
if (!$dbForProject->deleteDocument('memberships', $membership->getId())) {
|
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)) {
|
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
|
$deletes
|
||||||
|
@ -767,7 +767,7 @@ App::delete('/v1/teams/:teamId/memberships/:membershipId')
|
||||||
} catch (AuthorizationException $exception) {
|
} catch (AuthorizationException $exception) {
|
||||||
throw new Exception('Unauthorized permissions', 401, Exception::USER_UNAUTHORIZED);
|
throw new Exception('Unauthorized permissions', 401, Exception::USER_UNAUTHORIZED);
|
||||||
} catch (\Exception $exception) {
|
} 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', []);
|
$memberships = $user->getAttribute('memberships', []);
|
||||||
|
|
|
@ -51,7 +51,6 @@ class Exception extends \Exception
|
||||||
|
|
||||||
/** Teams */
|
/** Teams */
|
||||||
const TEAM_NOT_FOUND = 'team_not_found';
|
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_ALREADY_EXISTS = 'team_invite_already_exists';
|
||||||
const TEAM_INVITE_NOT_FOUND = 'team_invite_not_found';
|
const TEAM_INVITE_NOT_FOUND = 'team_invite_not_found';
|
||||||
const TEAM_INVALID_SECRET = 'team_invalid_secret';
|
const TEAM_INVALID_SECRET = 'team_invalid_secret';
|
||||||
|
@ -60,7 +59,6 @@ class Exception extends \Exception
|
||||||
|
|
||||||
/** Membership */
|
/** Membership */
|
||||||
const MEMBERSHIP_NOT_FOUND = 'membership_not_found';
|
const MEMBERSHIP_NOT_FOUND = 'membership_not_found';
|
||||||
const MEMBERSHIP_DELETION_FAILED = 'membership_deletion_failed';
|
|
||||||
|
|
||||||
/** Avatars */
|
/** Avatars */
|
||||||
const AVATAR_SET_NOT_FOUND = 'avatar_set_not_found';
|
const AVATAR_SET_NOT_FOUND = 'avatar_set_not_found';
|
||||||
|
|
Loading…
Reference in a new issue