优化异常返回

This commit is contained in:
zhouhao 2020-02-20 20:47:06 +08:00
parent ec73bfec95
commit f7775c9fce
1 changed files with 4 additions and 4 deletions

View File

@ -122,7 +122,9 @@ public class DeviceMessageController {
//设备功能调用
@PostMapping("invoked/{deviceId}/function/{functionId}")
@SneakyThrows
public Flux<?> invokedFunction(@PathVariable String deviceId, @PathVariable String functionId, @RequestBody Map<String, Object> properties) {
public Flux<?> invokedFunction(@PathVariable String deviceId,
@PathVariable String functionId,
@RequestBody Map<String, Object> properties) {
return registry
.getDevice(deviceId)
@ -134,8 +136,6 @@ public class DeviceMessageController {
.setParameter(properties))
.flatMapMany(FunctionInvokeMessageSender::send)
.map(mapReply(FunctionInvokeMessageReply::getOutput));
}
//获取设备所有属性
@ -162,7 +162,7 @@ public class DeviceMessageController {
}
T mapped = function.apply(reply);
if (mapped == null) {
throw new DeviceOperationException(ErrorCode.NO_REPLY);
throw new BusinessException(reply.getMessage(), reply.getCode());
}
return mapped;
};