当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionUtils类代码示例

本文整理汇总了Java中org.apache.commons.lang.exception.ExceptionUtils的典型用法代码示例。如果您正苦于以下问题:Java ExceptionUtils类的具体用法?Java ExceptionUtils怎么用?Java ExceptionUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExceptionUtils类属于org.apache.commons.lang.exception包,在下文中一共展示了ExceptionUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleRequestInternal

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
@RequestMapping(method = { RequestMethod.GET, RequestMethod.POST })
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Map<String, Object> map = new HashMap<String, Object>();

    String query = request.getParameter("query");
    if (query != null) {
        map.put("query", query);

        try {
            List<?> result = daoHelper.getJdbcTemplate().query(query, new ColumnMapRowMapper());
            map.put("result", result);
        } catch (DataAccessException x) {
            map.put("error", ExceptionUtils.getRootCause(x).getMessage());
        }
    }

    return new ModelAndView("db","model",map);
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:19,代码来源:DBController.java

示例2: getDelay

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
/**
 * Decide when the job should start run in first time
 * @return Seconds for the Job to start
 */
public int getDelay() {
  try {
    JobRunInfo lastRun = jobInfoStore.getLatestRun(this.identifier);

    if (lastRun != null && lastRun.isSucceed()) {
      Period
          period =
          new Period(new DateTime(lastRun.getStartTime()), DateTime.now(DateTimeZone.UTC));
      if (period.toStandardSeconds().getSeconds() < this.interval) {
        return (int) (this.interval - period.toStandardSeconds().getSeconds());
      }
    }
  } catch (Exception ex) {
    logger.error(ExceptionUtils.getRootCauseMessage(ex));
    logger.error(ExceptionUtils.getFullStackTrace(ex));
  }

  return random.nextInt(Configuration.getProperties().getInt("job_random_delay", 60));
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:24,代码来源:ExclusiveRecurringJobExecutor.java

示例3: getLatestRun

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
@Override
public JobRunInfo getLatestRun(String jobType) throws Exception {
  String path = String.format("%s/job/%s/latestrun", zkPath,
      jobType);
  ensureZkPathExists(path);
  byte[] data = ZkClient.getClient().getData().forPath(path);
  if (data != null && data.length > 0) {
    try {
      return mapper.readValue(IOUtils.toString(data, "UTF-8"), JobRunInfo.class);
    } catch (Exception e) {
      logger.error("Fail to read last run. Error {}", ExceptionUtils.getRootCauseMessage(e));
      return null;
    }
  } else {
    return null;
  }
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:18,代码来源:ZkJobInfoStore.java

示例4: calculateDailyInstanceCounts

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
private Boolean calculateDailyInstanceCounts() {

    try {

      DateTime utcNow = DateTime.now(DateTimeZone.UTC);

      List<Instance> instances = cloudInstanceStore.getInstances(region);
      List<ReservedInstances> reservedInstances = cloudInstanceStore.getReservedInstances(region);

      // Generate instance counts per type per Availability zone
      List<EsInstanceCountRecord> instanceCountRecords =
          getInstanceCountRecords(instances, reservedInstances, utcNow);
      logger.info("Number of instance count records {}", instanceCountRecords.size());

      // Insert records into soundwave store.
      instanceCounterStore.bulkInsert(instanceCountRecords);
      logger.info("Bulk insert succeeded for instance count records");

      return true;

    } catch (Exception e) {

      logger.error(ExceptionUtils.getRootCauseMessage(e));
      return false;
    }
  }
 
开发者ID:pinterest,项目名称:soundwave,代码行数:27,代码来源:DailyInstanceCountPerTypeJob.java

示例5: checkQueueLength

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
private void checkQueueLength() {
  try {
    GetQueueAttributesResult
        result =
        sqsClient.getQueueAttributes(queueUrl, Arrays.asList(QUEUELENGTHATTR,
            QUEUEINVISIBLEATTR));
    Map<String, String> attrs = result.getAttributes();

    if (attrs.containsKey(QUEUELENGTHATTR)) {
      Stats.addMetric(StatsUtil.getStatsName("healthcheck", "ec2queue_length"),
          Integer.parseInt(attrs.get(QUEUELENGTHATTR)));
      logger.info("Ec2 queue length is {}", attrs.get(QUEUELENGTHATTR));
    }

    if (attrs.containsKey(QUEUEINVISIBLEATTR)) {
      Stats.addMetric(StatsUtil.getStatsName("healthcheck", "ec2queue_in_processing"),
          Integer.parseInt(attrs.get("ApproximateNumberOfMessagesNotVisible")));
      logger.info("Ec2 queue in processing length is {}", attrs.get(QUEUEINVISIBLEATTR));
    }

  } catch (Exception ex) {
    logger.warn(ExceptionUtils.getRootCauseMessage(ex));
    logger.warn(ExceptionUtils.getFullStackTrace(ex));
  }

}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:27,代码来源:HealthCheckJob.java

示例6: deleteMessage

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
private void deleteMessage(String msgType, String msgId) {
    try {
        if ("namespace".equals(msgType)) {
            nsMessageProcessor.processNSDeleteMsg(msgId);
        } else {
            if ("cm_ci".equals(msgType)) {
                msgType = "ci";
               // relationMsgProcessor.processRelationDeleteMsg(msgId); //Delete all relation docs for given ci 
                indexer.getTemplate().delete(indexer.getIndexName(), ".percolator", msgId);//TEMP code: Till ciClassName is available try to delete all ciIds from percolator type also

                JsonObject object = new JsonObject();
                object.add("timestamp", new JsonPrimitive(new Date().getTime()));
                object.add("ciId", new JsonPrimitive(msgId));
                indexer.indexEvent("ci_delete", object.toString());
            } else if ("cm_ci_rel".equals(msgType)){
                return;                    // no longer deal with relation messages
            }
            indexer.getTemplate().delete(indexer.getIndexByType(msgType), msgType, msgId);
            logger.info("Deleted message with id::" + msgId + " and type::" + msgType + " from ES index:"+indexer.getIndexByType(msgType));
        }
    } catch (Exception e) {
        logger.error(">>>>>>>>Error in deleteMessage() ESMessageProcessorfor type :" + msgType+ " ::msgId :"+ msgId +"::" + ExceptionUtils.getMessage(e), e);
    }
}
 
开发者ID:oneops,项目名称:oneops,代码行数:25,代码来源:ESMessageProcessor.java

示例7: isInterrupt

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
protected boolean isInterrupt(Throwable e) {
    if (!running) {
        return true;
    }

    if (e instanceof InterruptedException || e instanceof ZkInterruptedException) {
        return true;
    }

    if (ExceptionUtils.getRootCause(e) instanceof InterruptedException) {
        return true;
    }

    return false;

}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:17,代码来源:GlobalTask.java

示例8: perform

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
@Override
public void perform() throws IOException {
    try {
        this.original.perform();
    } catch (final IOException | RuntimeException ex) {
        final Issue created = this.github.repos()
            .get(new Coordinates.Simple("amihaiemil/comdor"))
            .issues()
            .create(
                "Exception occured while peforming an Action!",
                String.format(
                    "@amihaiemil Something went wrong, please have a look."
                    + "\n\n[Here](%s) are the logs of the Action.",
                    this.original.log().location()
                )
                + "\n\nHere is the exception:\n\n```\n\n"
                + ExceptionUtils.getStackTrace(ex) + "\n\n```"
            );
        this.original.log().logger().info(
            "Opened Issue https://github.com/amihaiemil/comdor/issues/"
            + created.number()
        );
    }
}
 
开发者ID:amihaiemil,项目名称:comdor,代码行数:25,代码来源:VigilantAction.java

示例9: listSoortAdministratieveHandelingen

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
/**
 * Haal een lijst van items op.
 * @param bijhoudingsautorisatieId bijhoudingsautorisatie ID
 * @param parameters request parameters
 * @param pageable paginering
 * @return lijst van item (inclusief paginering en sortering)
 */
@RequestMapping(value = "/{id}/bijhoudingsautorisatieSoortAdministratieveHandelingen", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public final Page<BijhoudingsautorisatieSoortAdministratieveHandelingView> listSoortAdministratieveHandelingen(
        @PathVariable("id") final Integer bijhoudingsautorisatieId,
        @RequestParam final Map<String, String> parameters,
        @PageableDefault(size = 1000) final Pageable pageable) {
    return getReadonlyTransactionTemplate().execute(status -> {
        try {
            final Bijhoudingsautorisatie bijhoudingsautorisatie = get(bijhoudingsautorisatieId);
            // Aangezien de page die we terugkrijgen uit de repository immutable is, maken we een nieuwe lijst aan om
            // vervolgens een nieuw page object aan te maken met de betreffende subset van de lijst.
            final List<BijhoudingsautorisatieSoortAdministratieveHandelingView> schermSoorten =
                    bepaalActiefStatusSoortAdministratieveHandelingen(bijhoudingsautorisatie);
            final int fromIndex = pageable.getOffset();
            final int toIndex = (fromIndex + pageable.getPageSize()) > schermSoorten.size() ? schermSoorten.size() : fromIndex + pageable.getPageSize();
            return new PageImpl<>(schermSoorten.subList(fromIndex, toIndex), pageable, schermSoorten.size());
        } catch (NotFoundException exception) {
            LOG.error(ExceptionUtils.getFullStackTrace(exception));
            return null;
        }
    });
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:30,代码来源:BijhoudingsautorisatieController.java

示例10: LibraryMatchRead

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
public static TargetMatchScoring LibraryMatchRead(String Filename, String LibID) throws FileNotFoundException {

        if (!new File(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.serFS").exists()) {
            return null;
        }
        TargetMatchScoring match = null;
        try {
            Logger.getRootLogger().info("Loading Target library match results to file:" + FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.serFS...");
            FileInputStream fileIn = new FileInputStream(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.serFS");
            FSTObjectInput in = new FSTObjectInput(fileIn);
            match = (TargetMatchScoring) in.readObject();
            in.close();
            fileIn.close();
        } catch (Exception ex) {
            Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
            return null;
        }
        return match;
    }
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:20,代码来源:TargetMatchScoring.java

示例11: LibraryMatchReadJS

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
public static TargetMatchScoring LibraryMatchReadJS(String Filename, String LibID) throws FileNotFoundException {

        if (!new File(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.serFS").exists()) {
            return null;
        }
        TargetMatchScoring match = null;
        try {
            Logger.getRootLogger().info("Loading Target library match results to file:" + FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.ser...");
            FileInputStream fileIn = new FileInputStream(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.ser");
            ObjectInputStream in = new ObjectInputStream(fileIn);
            match = (TargetMatchScoring) in.readObject();
            in.close();
            fileIn.close();
        } catch (Exception ex) {
            Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
            return null;
        }
        return match;
    }
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:20,代码来源:TargetMatchScoring.java

示例12: FoundInInclusionMZList

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
private boolean FoundInInclusionMZList(float rt, float mz) {
    if (InclusionRT.PointCount() == 0) {
        return false;
    }
    float lowrt = rt - parameter.MaxCurveRTRange;
    float highrt = rt + parameter.MaxCurveRTRange;
    float lowmz = InstrumentParameter.GetMzByPPM(mz, 1, PPM);
    float highmz = InstrumentParameter.GetMzByPPM(mz, 1, -PPM);

    Object[] found = null;
    try {
        found = InclusionRange.range(new double[]{lowrt, lowmz}, new double[]{highrt, highmz});
    } catch (KeySizeException ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
    }
    if (found != null && found.length > 0) {
        return true;
    }
    return false;
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:21,代码来源:PDHandlerBase.java

示例13: FoundInInclusionList

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
private boolean FoundInInclusionList(float mz, float startrt, float endrt) {
    if (InclusionRT.PointCount() == 0) {
        return false;
    }
    float lowmz = InstrumentParameter.GetMzByPPM(mz, 1, PPM);
    float highmz = InstrumentParameter.GetMzByPPM(mz, 1, -PPM);
    float lowrt = startrt - parameter.RTtol;
    float highrt = endrt + parameter.RTtol;

    Object[] found = null;
    try {
        found = InclusionRange.range(new double[]{lowrt, lowmz}, new double[]{highrt, highmz});
    } catch (KeySizeException ex) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
    }
    if (found != null && found.length > 0) {
        for (Object point : found) {
            InclusionFound.put((XYData) point, true);
        }
        return true;
    }
    return false;
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:24,代码来源:PDHandlerBase.java

示例14: FasterSerialzationRead

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
public static FastaParser FasterSerialzationRead(String Filename) throws FileNotFoundException {

        if (!new File(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + ".FastaSer").exists()) {
            return null;
        }
        FastaParser fastareader = null;
        try {
            org.apache.log4j.Logger.getRootLogger().info("Loading fasta serialization to file:" + FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + ".FastaSer..");
            FileInputStream fileIn = new FileInputStream(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + ".FastaSer");
            FSTObjectInput in = new FSTObjectInput(fileIn);
            fastareader = (FastaParser) in.readObject();
            in.close();
            fileIn.close();
        } catch (Exception ex) {
            org.apache.log4j.Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex));
            return null;
        }

        return fastareader;
    }
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:21,代码来源:FastaParser.java

示例15: PepXMLParser

import org.apache.commons.lang.exception.ExceptionUtils; //导入依赖的package包/类
public PepXMLParser(LCMSID singleLCMSID, String FileName, float threshold, boolean CorrectMassDiff) throws ParserConfigurationException, SAXException, IOException, XmlPullParserException {
    this.singleLCMSID = singleLCMSID;
    this.CorrectMassDiff = CorrectMassDiff;
    this.FileName = FileName;
    this.threshold = threshold;
    Logger.getRootLogger().info("Parsing pepXML: " + FileName + "....");
    try {
        ParseSAX();
    } catch (Exception e) {
        Logger.getRootLogger().error(ExceptionUtils.getStackTrace(e));
        Logger.getRootLogger().info("Parsing pepXML: " + FileName + " failed. Trying to fix the file...");
        insert_msms_run_summary(new File(FileName));
        ParseSAX();
    }
    //System.out.print("done\n");
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:17,代码来源:PepXMLParser.java


注:本文中的org.apache.commons.lang.exception.ExceptionUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。