-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
I'm using an HTTP-triggered function like this:
public static IActionResult GetAllAvailabilityOnDate(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "availability/{datefilter:regex(^\\d{{4}}-\\d{{2}}-\\d{{2}}$)}")] HttpRequest req,
[Sql("SELECT * FROM dbo.Availability a " +
"WHERE a.Date = @DateFilter ",
CommandType = CommandType.Text,
Parameters = "@DateFilter={datefilter}",
ConnectionStringSetting = "DatabaseConnectionString")] IEnumerable<MyResult> res,
string dateFilter,
ILogger log)
{
This works all great - until a user provides some bogus input like "0000-00-00". In this case the Function errors out with
System.Private.CoreLib: Exception while executing function: GetAllAvailabilityOnDate. Microsoft.Azure.WebJobs.Host: Exception binding parameter 'res'. Core Microsoft SqlClient Data Provider: Conversion failed when converting date and/or time from character string.
The Function immediately returns a 500 result. However, I would like to be able to insert some custom error handling and for example return a 400-Bad Request instead.
Is this something that's already somehow possible? If not, I would like to make this an enhancement request :)
pudgypal
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request