Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.92k stars 442 forks source link

Allow custom error responses in javascipt/typescript. [httpTrigger] #7640

Closed jahead closed 2 years ago

jahead commented 3 years ago

What problem would the feature you're requesting solve? Please describe.

I've spent the day researching for the best solution for this in the javascript/typescript world, and I can't seem to find a good solution.

Ability to customize error response messages. in the ts/js environment.

Describe the solution you'd like

We would like to: a) have RFC7807 complaint responses from our azure functions, or some form of standard error json response b) have 500s failures show in Application Insight's failures tab. c) (ideally) have to have the ability to customize the response.

We don't mind the notion that "if you catch and handle" the function executed successfully and if you throw or re-throw it's a failed function. We would just like to customize the error response message so we can: a) have consistent client interaction across our services. b) supply helpful information.

As we see it, 4xx aren't failures, they are the mostly always the consumers fault. We don't care as much. so we don't need to/want to see them in the failures tab. 500s errors though are things going horribly wrong, an unhanded code path, miss-configured servers, dependent services are down etc. They should be showing up in the failures tab with a full stack trace. but we can't currently, (or atleast in a obvious way) have nicely formatted error messages and a nice integrated logging experience

Describe alternatives you've considered

Using a different logging product, e.g sentry. Would rather not. Having to write out our own telemetry to Application Insights, not sure if that would show up in failures. Writing custom logging queries. Would rather use the feature rich Failures tab.

v-anvari commented 3 years ago

Thank you for your feedback! We will investigate this scenario and update you with the possibilities.

v-anvari commented 3 years ago

Hi @jahead , Can you provide a sample code. Any samples that could explain this scenarios usage

ghost commented 2 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

jahead commented 2 years ago

Hey sorry, I've been on a sprint, I'll give you the feedback tonight, please re-open

ghost commented 2 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.