Skip to content

Commit b3e41cd

Browse files
committed
[PM-2844] Updated SyncController and PolicyService to use some ErrorCodes for exceptions
1 parent e1f20ad commit b3e41cd

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Api/Vault/Controllers/SyncController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Bit.Api.Vault.Models.Response;
2+
using Bit.Core;
23
using Bit.Core.Entities;
34
using Bit.Core.Enums;
45
using Bit.Core.Enums.Provider;
@@ -59,7 +60,7 @@ public async Task<SyncResponseModel> Get([FromQuery] bool excludeDomains = false
5960
var user = await _userService.GetUserByPrincipalAsync(User);
6061
if (user == null)
6162
{
62-
throw new BadRequestException("User not found.");
63+
throw new BadRequestException(ErrorCodes.UserNotFound);
6364
}
6465

6566
var organizationUserDetails = await _organizationUserRepository.GetManyDetailsByUserAsync(user.Id,

src/Core/Services/Implementations/PolicyService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public async Task SaveAsync(Policy policy, IUserService userService, IOrganizati
4949

5050
if (!org.UsePolicies)
5151
{
52-
throw new BadRequestException("This organization cannot use policies.");
52+
throw new BadRequestException(ErrorCodes.OrganizationCannotUsePolicies);
5353
}
5454

5555
// Handle dependent policy checks
@@ -281,7 +281,7 @@ private async Task RequiredBySsoTrustedDeviceEncryptionAsync(Organization org)
281281
var ssoConfig = await _ssoConfigRepository.GetByOrganizationIdAsync(org.Id);
282282
if (ssoConfig?.GetData()?.MemberDecryptionType == MemberDecryptionType.TrustedDeviceEncryption)
283283
{
284-
throw new BadRequestException("Trusted device encryption is on and requires this policy.");
284+
throw new BadRequestException(ErrorCodes.PolicyRequiredByTrustedDeviceEncryption);
285285
}
286286
}
287287
}

0 commit comments

Comments
 (0)