Azure / Azure/azure-functions-java-worker

Catching uncaught exceptions by means of request hooks

未关闭
#273 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
needs-investigation New Feature reviewed
主要语言
Java
星标
103
派生
74
平均合并
4 天 8 小时
30 天内合并 PR
2

描述

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

贡献指南

打开贡献指南

调研方向

该 issue 未指定文件、测试或 worker 入口点。首先定位 Java worker 的请求执行路径和异常处理路径,然后确定是否已经存在 pre/post hook;当已实现并通过测试覆盖一项达成共识的 hook 或异常处理设计时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
azure, java, kotlin
领域
backend, cloud
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。