This repository was archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Document compatiblity switch for input formatter exceptions #7169
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
...crosoft.AspNetCore.Mvc.Abstractions/Formatters/InputFormatterExceptionModelStatePolicy.cs
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
src/Microsoft.AspNetCore.Mvc.Abstractions/Formatters/InputFormatterExceptionPolicy.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // 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; | ||
|
|
||
| namespace Microsoft.AspNetCore.Mvc.Formatters | ||
| { | ||
| /// <summary> | ||
| /// Defines the set of policies that determine how the model binding system interprets exceptions | ||
| /// thrown by an <see cref="IInputFormatter"/>. Applications should set | ||
| /// <c>MvcOptions.InputFormatterExceptionPolicy</c> to configure this setting. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <para> | ||
| /// An <see cref="IInputFormatter"/> could throw an exception for several reasons, including: | ||
| /// <list type="bullet"> | ||
| /// <item><description>malformed input</description></item> | ||
| /// <item><description>client disconnect or other I/O problem</description></item> | ||
| /// <item><description> | ||
| /// application configuration problems such as <see cref="TypeLoadException"/> | ||
| /// </description></item> | ||
| /// </list> | ||
| /// </para> | ||
| /// <para> | ||
| /// The policy associated with <see cref="InputFormatterExceptionPolicy.AllExceptions"/> treats | ||
| /// all such categories of problems as model state errors, and usually will be reported to the client as | ||
| /// an HTTP 400. This was the only policy supported by model binding in ASP.NET Core MVC 1.0, 1.1, and 2.0 | ||
| /// and is still the default for historical reasons. | ||
| /// </para> | ||
| /// <para> | ||
| /// The policy associated with <see cref="InputFormatterExceptionPolicy.MalformedInputExceptions"/> | ||
| /// treats only <see cref="InputFormatterException"/> and its subclasses as model state errors. This means that | ||
| /// exceptions that are not related to the content of the HTTP request (such as a disconnect) will be rethrown, | ||
| /// which by default would cause an HTTP 500 response, unless there is exception-handling middleware enabled. | ||
| /// </para> | ||
| /// </remarks> | ||
| public enum InputFormatterExceptionPolicy | ||
| { | ||
| /// <summary> | ||
| /// This value indicates that all exceptions thrown by an <see cref="IInputFormatter"/> will be treated | ||
| /// as model state errors. | ||
| /// </summary> | ||
| AllExceptions = 0, | ||
|
|
||
| /// <summary> | ||
| /// This value indicates that only <see cref="InputFormatterException"/> and subclasses will be treated | ||
| /// as model state errors. All other exceptions types will be rethrown and can be handled by a higher | ||
| /// level exception handler, such as exception-handling middleware. | ||
| /// </summary> | ||
| MalformedInputExceptions = 1, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm alphabetizing these things as I go. There's a ton of them so it seems worth doing. I'll another PR at the end to cover the rest.