1. <i id='zicYO'><tr id='zicYO'><dt id='zicYO'><q id='zicYO'><span id='zicYO'><b id='zicYO'><form id='zicYO'><ins id='zicYO'></ins><ul id='zicYO'></ul><sub id='zicYO'></sub></form><legend id='zicYO'></legend><bdo id='zicYO'><pre id='zicYO'><center id='zicYO'></center></pre></bdo></b><th id='zicYO'></th></span></q></dt></tr></i><div id='zicYO'><tfoot id='zicYO'></tfoot><dl id='zicYO'><fieldset id='zicYO'></fieldset></dl></div>

    <small id='zicYO'></small><noframes id='zicYO'>

      <bdo id='zicYO'></bdo><ul id='zicYO'></ul>
  2. <tfoot id='zicYO'></tfoot>
    1. <legend id='zicYO'><style id='zicYO'><dir id='zicYO'><q id='zicYO'></q></dir></style></legend>

      SonarQube:(改为获取特定异常子类型的列表)

      时间:2024-05-09

      <small id='CMb1O'></small><noframes id='CMb1O'>

          <bdo id='CMb1O'></bdo><ul id='CMb1O'></ul>

                <tbody id='CMb1O'></tbody>
            • <i id='CMb1O'><tr id='CMb1O'><dt id='CMb1O'><q id='CMb1O'><span id='CMb1O'><b id='CMb1O'><form id='CMb1O'><ins id='CMb1O'></ins><ul id='CMb1O'></ul><sub id='CMb1O'></sub></form><legend id='CMb1O'></legend><bdo id='CMb1O'><pre id='CMb1O'><center id='CMb1O'></center></pre></bdo></b><th id='CMb1O'></th></span></q></dt></tr></i><div id='CMb1O'><tfoot id='CMb1O'></tfoot><dl id='CMb1O'><fieldset id='CMb1O'></fieldset></dl></div>

              • <legend id='CMb1O'><style id='CMb1O'><dir id='CMb1O'><q id='CMb1O'></q></dir></style></legend><tfoot id='CMb1O'></tfoot>
                本文介绍了SonarQube:(改为获取特定异常子类型的列表)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个关于通用异常的问题.当您尝试执行多项操作时,我们如何知道要使用哪个非泛型异常.

                I have a question about generic exceptions. How would we know which non-generic exception to use when you have a try that does multiple things.

                例如:

                  @PostConstruct
                    protected void init() {
                        try {
                            HttpSession session = request.getSession();
                            String policyInfo = (String) session.getAttribute("policyInfo");
                            if(session.getAttribute("faxNumber") != null) {
                                faxNumber = (String) session.getAttribute("faxNumber");
                            }
                            policyNumber = (String) session.getAttribute("policyNumber");
                            JSONObject policyInfoObj = new JSONObject(policyInfo);
                            JSONArray policiesArr = policyInfoObj.getJSONArray("policies");
                            if (policiesArr.length() > 0) {
                                JSONObject policyObj = policiesArr.getJSONObject(0);
                                JSONArray insuredVehicle = policyObj.getJSONArray("insuredVehicle");
                                checkInsuredVechile(insuredVehicle);
                                termStartDate = policyObj.getString("effectiveDate");
                                JSONArray addressArray = policyObj.getJSONArray("address");
                                policySource = policyObj.getString("policySource");
                                checkAddressArry(addressArray);
                
                            }
                            
                             
                             
                            policyNumber = policyNumber.substring(0,5)+"-"+policyNumber.substring(5,7)+"-"+policyNumber.substring(7);
                            
                            response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
                        }catch(Exception  e) {
                            logger.error("Exception in getting policy details",e);
                        }
                    }
                

                所以对于 catch(Exception e) { 它将需要一个非泛型异常,但我无法确定它可能是什么.

                So for catch(Exception e) { it will need a non-generic exception, but I am having trouble to determine what it can be.

                推荐答案

                您应该只捕获特定的异常,例如:

                You should catch only specific exeption like:

                catch(org.json.JsonException e)
                

                而不是基类Exception,这意味着所有可能的已检查和未检查的异常

                and not the base class Exception, which means all possible checked and unchecked Exceptions

                这篇关于SonarQube:(改为获取特定异常子类型的列表)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:SONAR 问题 - 关闭此 FileInputStream 下一篇:声纳违规:“方法可能无法在异常时关闭流"

                相关文章

                <legend id='mIZCq'><style id='mIZCq'><dir id='mIZCq'><q id='mIZCq'></q></dir></style></legend>

                    <bdo id='mIZCq'></bdo><ul id='mIZCq'></ul>
                    <tfoot id='mIZCq'></tfoot>
                  1. <i id='mIZCq'><tr id='mIZCq'><dt id='mIZCq'><q id='mIZCq'><span id='mIZCq'><b id='mIZCq'><form id='mIZCq'><ins id='mIZCq'></ins><ul id='mIZCq'></ul><sub id='mIZCq'></sub></form><legend id='mIZCq'></legend><bdo id='mIZCq'><pre id='mIZCq'><center id='mIZCq'></center></pre></bdo></b><th id='mIZCq'></th></span></q></dt></tr></i><div id='mIZCq'><tfoot id='mIZCq'></tfoot><dl id='mIZCq'><fieldset id='mIZCq'></fieldset></dl></div>
                  2. <small id='mIZCq'></small><noframes id='mIZCq'>