mirror of
https://github.com/bitwarden/server.git
synced 2025-07-07 02:52:50 -05:00
initial commit of source
This commit is contained in:
30
src/Core/Exceptions/BadRequestException.cs
Normal file
30
src/Core/Exceptions/BadRequestException.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||
|
||||
namespace Bit.Core.Exceptions
|
||||
{
|
||||
public class BadRequestException : Exception
|
||||
{
|
||||
public BadRequestException(string message) : this(string.Empty, 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; }
|
||||
}
|
||||
}
|
6
src/Core/Exceptions/NotFoundException.cs
Normal file
6
src/Core/Exceptions/NotFoundException.cs
Normal file
@ -0,0 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace Bit.Core.Exceptions
|
||||
{
|
||||
public class NotFoundException : Exception { }
|
||||
}
|
Reference in New Issue
Block a user