Skip to content

Catching uncaught exceptions by means of request hooks #273

Open
@srmds

Description

@srmds

Investigative information

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: an Exception Listener)?

Repro steps

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"
    }
}

Expected behavior

A post-hook interface that creates the ability to implement the interface and define behaviour of pre/post-execution and on exception behaviour, for example:

interface PostExecutionRequestHandler {
    fun onException(exception: ExecutionException)
}

Copied from original issue: Azure/azure-functions-java-library#82

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions