Commit a4bb5177d57a0f272640ca78e195ead76425dda5
1 parent
f843922c
fix: [DEFECT-1550] 新增、编辑存在的设备名称时,没有把异常正确返回给前端
Showing
1 changed file
with
5 additions
and
2 deletions
... | ... | @@ -126,7 +126,7 @@ public class TkDeviceController extends BaseController { |
126 | 126 | newDeviceDTO = |
127 | 127 | tkdeviceService.insertOrUpdate(getCurrentUser().getCurrentTenantId(), deviceDTO); |
128 | 128 | } catch (Exception e) { |
129 | - if (created) { | |
129 | + if (created && null !=savedDevice) { | |
130 | 130 | logEntityAction( |
131 | 131 | getCurrentUser(), |
132 | 132 | savedDevice.getId(), |
... | ... | @@ -135,8 +135,11 @@ public class TkDeviceController extends BaseController { |
135 | 135 | created ? ActionType.ADDED : ActionType.UPDATED, |
136 | 136 | e); |
137 | 137 | deleteTbDevice(selfTbIdStr); |
138 | - throw handleException(e); | |
139 | 138 | } |
139 | + if(e instanceof TkDataValidationException){ | |
140 | + throw new TkDataValidationException(e.getMessage()); | |
141 | + } | |
142 | + throw handleException(e); | |
140 | 143 | } |
141 | 144 | return ResponseEntity.ok(newDeviceDTO); |
142 | 145 | } | ... | ... |