1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-27 03:41:30 +01:00
bitwarden-server/src/Core/Exceptions/BadRequestException.cs
Rui Tomé 8325f0eed4
[EC-508] SCIM CQRS Refactor - Users/Get (#2266)
* [EC-390] Added Scim.Test unit tests project

* [EC-390] Added ConflictException type. Updated BadRequestException to have parameterless constructor. Updated NotFoundException to have constructor with a message parameter

* [EC-534] Implemented CQRS for Users Get and added unit tests

* [EC-508] Renamed GetUserCommand to GetUserQuery

* [EC-508] Created ScimServiceCollectionExtensions

* [EC-508] Renamed AddScimCommands to AddScimUserQueries

* [EC-508] Created ExceptionHandlerFilterAttribute on SCIM project

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
2022-10-04 11:40:28 +10:00

34 lines
802 B
C#

using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace Bit.Core.Exceptions;
public class BadRequestException : Exception
{
public BadRequestException() : base()
{ }
public BadRequestException(string message)
: base(message)
{ }
public BadRequestException(string key, string errorMessage)
: base("The model state is invalid.")
{
ModelState = new ModelStateDictionary();
ModelState.AddModelError(key, errorMessage);
}
public BadRequestException(ModelStateDictionary modelState)
: base("The model state is invalid.")
{
if (modelState.IsValid || modelState.ErrorCount == 0)
{
return;
}
ModelState = modelState;
}
public ModelStateDictionary ModelState { get; set; }
}