Azure / azure-functions-java-library

Contains annotations for writing Azure Functions in Java
MIT License
43 stars 43 forks source link

Catching uncaught exceptions #82

Closed srmds closed 5 years ago

srmds commented 5 years ago

My question is two-folded:

1) I would like to know if there is a notion of pre-execution and post-execution hooks, meaning: when a function is invoked, are there hooks exposed that will be called before and after the function handler is invoked?

2) Is there a way by means of a post-hook to catch uncaught exceptions? If not, what alternative can I use?

For example, if I have a function handler like below (which is written in Kotlin), what abilities can I utilise to catch an exception if one occurs, that is not explicitly caught by a try/catch block?

class Function {

    fun foobar(name: String?, context: ExecutionContext): String {

        // mimicking an uncaught exception
        throw Exception()

        return "Foobar"
    }
}
kulkarnisonia16 commented 5 years ago

Tracking it - https://github.com/Azure/azure-functions-java-worker/issues/273