// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace Microsoft.AspNetCore.Mvc
{
///
/// An that when executed will produce a Bad Request (400) response.
///
public class BadRequestObjectResult : ObjectResult
{
///
/// Creates a new instance.
///
/// Contains the errors to be returned to the client.
public BadRequestObjectResult(object error)
: base(error)
{
StatusCode = StatusCodes.Status400BadRequest;
}
///
/// Creates a new instance.
///
/// containing the validation errors.
public BadRequestObjectResult(ModelStateDictionary modelState)
: base(new SerializableError(modelState))
{
if (modelState == null)
{
throw new ArgumentNullException(nameof(modelState));
}
StatusCode = StatusCodes.Status400BadRequest;
}
}
}