Azure / Azure/azure-functions-java-worker

Catching uncaught exceptions by means of request hooks

Offen
#273 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
needs-investigation New Feature reviewed
Vorherrschende Sprache
Java
Sterne
103
Forks
74
Ø Merge
4 T. 8 Std.
Gemergte PRs (30 T.)
2

Beschreibung

#### 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?

```kotlin
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:

```kotlin
interface PostExecutionRequestHandler {
fun onException(exception: ExecutionException)
}
```

Copied from original issue: [Azure/azure-functions-java-library#82](https://github.com/Azure/azure-functions-java-library/issues/82)

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Das Issue nennt keine Dateien, Tests oder Worker-Einstiegspunkte. Beginne damit, die Pfade für die Request-Ausführung und die Ausnahmebehandlung des Java-Workers zu lokalisieren, und ermittle anschließend, ob bereits Pre-/Post-Hooks vorhanden sind; abgeschlossen ist die Arbeit, wenn ein vereinbartes Hook- oder Ausnahmebehandlungsdesign implementiert und durch Tests abgedeckt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, java, kotlin
Bereich
backend, cloud
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.