当我尝试在控制器方法中捕获异常时,我无法捕获 SocketException。控制器动作如下所示:
def updateDeviceStartV1() {
try {
...
response.status = 200;
response.setContentType("application/octet-stream")
response.outputStream << responseService.encryptedResponse // byte[]
}
catch(Exception e) {
log.error "Server faced unexpected exception", e
response.status = 500;
...
}
SocketException 由“response.outputStream << responseService.encryptedResponse”行抛出,因为客户端意外关闭了连接。然而,这个异常并没有被捕获,控制台接收到标准的异常显示......
难道我做错了什么?