Skip to content

Commit

Permalink
Ensuring exception message is used if ModelError.Message is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiocav committed Jul 9, 2024
1 parent 005f9dc commit d6dfbae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

### Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore <version>

- <entry>
- Fixed a bug that would lead to an empty exception message in some model binding failures.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,16 @@ internal sealed class FromBodyConversionFeature : IFromBodyConversionFeature

foreach (var error in dictionary.Errors)
{
messageBuilder.AppendLine(error.ErrorMessage);
if (error is null)
{
continue;
}

var message = string.IsNullOrEmpty(error.ErrorMessage)
? error.Exception?.Message
: error.ErrorMessage;

messageBuilder.AppendLine(message);
}
}

Expand Down

0 comments on commit d6dfbae

Please sign in to comment.