Files
server/src/Core/Exceptions/BadRequestException.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
855 B
C#
Raw Normal View History

2015-12-08 22:57:38 -05:00
using System;
2016-05-19 19:10:24 -04:00
using Microsoft.AspNetCore.Mvc.ModelBinding;
2015-12-08 22:57:38 -05:00
namespace Bit.Core.Exceptions
{
public class BadRequestException : Exception
{
public BadRequestException(string message)
: base(message)
{ }
2015-12-08 22:57:38 -05:00
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)
2015-12-08 22:57:38 -05:00
{
return;
}
ModelState = modelState;
}
public ModelStateDictionary ModelState { get; set; }
}
}