例外要在Java登录



我是Java世界的新手,也许问一个非常有争议的问题,从例外情况下记录最佳实践,我有以下代码,请让我知道错误的是,因为当我针对声纳Qube扫描此代码时,它确实报告了必须记录或重新登录例外的问题

 public ResponseEntity<mainDTO> updateMain(@RequestBody mainDTO domainDTO)
            throws RNNotFoundException {
        try {
            return ResponseEntity.ok(mainService.update(mainDTO));
        } catch (RNNotFoundException e) {
            logger.error("Exception in updatemain"+ e.getMessage());
            throw e;
        }catch (Exception e) {
            logger.error(e.getMessage());
            throw e;
        }
    }

您不应使用throws rnnotfoundException和Try-Catch块一起使用。

如果您要在parent方法中捕获rnnotfoundexception exceptiation,则在此处删除try-catch块。

如果您没有从任何地方删除throws rnnotfoundException。

最新更新