mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
增加ExceptionFilter和DefaultExceptionFilter支持异常处理
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package cn.hutool.http.server;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.http.server.filter.DefaultExceptionFilter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ExceptionServerTest {
|
||||
public static void main(final String[] args) {
|
||||
HttpUtil.createServer(8888)
|
||||
.addFilter(new DefaultExceptionFilter())
|
||||
.addAction("/", (req, res) -> {
|
||||
throw new RuntimeException("Test Exception");
|
||||
})
|
||||
.start();
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package cn.hutool.http.server;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Issue3568Test {
|
||||
public static void main(String[] args) {
|
||||
HttpUtil.createServer(8888)
|
||||
.addHandler("/", httpExchange -> {
|
||||
throw new IOException("111");
|
||||
})
|
||||
.start();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user