I've got an azure function that contains some logic with a pretty basic try catch (code shortened for brevity)
try {
// do logic here that can potentially fail
} catch (ex) {
context.log(`Log details about the exception: ${ex.message}`);
context.res = {
status: 500,
headers: {
"Content-Type": "application/json"
},
body: {
message: ex.message
}
};
return;
}
So in the event of an exception during that logic I handle the exception and gracefully return in the http response and terminate the app. I would expect that azure functions would consider 500 status code's as failure (considering they're internal server errors), but my function is still considered to have successfully executed. Considering this a low volume function with somewhat high importance for it's context, I was to be notified about all failures.
What's the intelligent thing to do error? Do I throw an exception here instead of simply returning?