List of usage examples for java.lang RuntimeException toString
public String toString()
From source file:eu.redzoo.article.javaworld.stability.service.payment.SyncPaymentService.java
@Path("paymentmethods") @GET/* w w w .j ava 2 s .c o m*/ @Produces(MediaType.APPLICATION_JSON) public ImmutableSet<PaymentMethod> getPaymentMethods(@QueryParam("addr") String address) { Score score = NEUTRAL; try { ImmutableList<Payment> pmts = paymentDao.getPayments(address, 50); score = pmts.isEmpty() ? client.target(creditScoreURI).queryParam("addr", address).request().get(Score.class) : (pmts.stream().filter(pmt -> pmt.isDelayed()).count() >= 1) ? NEGATIVE : POSITIVE; } catch (RuntimeException rt) { LOG.fine("error occurred by calculating score. Fallback to " + score + " " + rt.toString()); } return SCORE_TO_PAYMENTMETHOD.apply(score); }
From source file:com.github.omadahealth.circularbarpager.library.viewpager.WrapContentViewPager.java
/** * Allows to redraw the view size to wrap the content of the bigger child. * * @param widthMeasureSpec with measured * @param heightMeasureSpec height measured *///from w ww . ja v a 2 s.com @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { try { int mode = MeasureSpec.getMode(heightMeasureSpec); if (mode == MeasureSpec.UNSPECIFIED || mode == MeasureSpec.AT_MOST) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int height = 0; for (int i = 0; i < getChildCount(); i++) { View child = getChildAt(i); if (child != null) { child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); int h = child.getMeasuredHeight(); if (h > height) { height = h; } } } heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); } catch (RuntimeException e) { Log.e(TAG, "Exception during WrapContentViewPager onMeasure " + e.toString()); } }
From source file:org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.EqualToExpr.java
@Override public Result getNextBoolean() throws ExecException { try {//from w w w . j a v a 2 s . co m Result left, right; switch (operandType) { case DataType.BYTEARRAY: case DataType.DOUBLE: case DataType.FLOAT: case DataType.BOOLEAN: case DataType.INTEGER: case DataType.BIGINTEGER: case DataType.BIGDECIMAL: case DataType.LONG: case DataType.DATETIME: case DataType.CHARARRAY: case DataType.TUPLE: case DataType.MAP: { Result r = accumChild(null, operandType); if (r != null) { return r; } left = lhs.getNext(operandType); right = rhs.getNext(operandType); return doComparison(left, right); } default: { int errCode = 2067; String msg = this.getClass().getSimpleName() + " does not know how to " + "handle type: " + DataType.findTypeName(operandType); throw new ExecException(msg, errCode, PigException.BUG); } } } catch (RuntimeException e) { throw new ExecException("exception while executing " + this.toString() + ": " + e.toString(), 2067, PigException.BUG, e); } }
From source file:net.solarnetwork.node.control.modbus.heartbeat.ModbusHeartbeatJob.java
@Override protected void executeInternal(JobExecutionContext jobContext) throws Exception { final DateTime heartbeatDate = new DateTime(); String heartbeatMessage = null; boolean heartbeatSuccess = false; try {//w w w . jav a2 s . co m final Boolean executed = setValue(registerValue); if (executed == null) { // hmm, how can this be localized? heartbeatMessage = "No Modbus connection available."; } else if (executed.booleanValue() == false) { heartbeatMessage = "Unknown Modbus error."; } else { // good heartbeatSuccess = true; } } catch (RuntimeException e) { log.error("Error sending heartbeat message: {}", e.toString()); Throwable root = e; while (root.getCause() != null) { root = root.getCause(); } heartbeatMessage = "Error: " + root.getMessage(); } STATUS_MAP.put(getStatusKey(), new JobStatus(heartbeatDate, heartbeatSuccess, heartbeatMessage)); }
From source file:com.ariatemplates.seleniumjavarobot.executor.Executor.java
private void executeCall(Map<String, Object> curCall) throws InterruptedException { try {//w ww . j av a 2s . c om String curEventName = (String) curCall.get("name"); String id = (String) curCall.get("id"); @SuppressWarnings("unchecked") List<Object> args = (List<Object>) curCall.get("args"); Method curMethod = methods.get(curEventName); SeleniumJavaRobot.log(String.format("Executing %s (%s)", curEventName, args)); Object result; boolean success = false; try { result = curMethod.run(this, args); success = true; } catch (RuntimeException e) { result = e.toString(); } synchronized (robotizedBrowser) { driver.executeScript( "try { window.SeleniumJavaRobot.__callback(arguments[0], arguments[1], arguments[2]); } catch(e){}", id, success, result); } } catch (RuntimeException e) { System.err.println(e); } }
From source file:com.github.omadahealth.circularbarpager.library.viewpager.WrapContentViewPager.java
/** * Fixes for "java.lang.IndexOutOfBoundsException Invalid index 0, size is 0" * on "android.support.v4.view.ViewPager.performDrag" *//*w w w . j av a 2s. c om*/ @Override public boolean onInterceptTouchEvent(MotionEvent event) { try { if (event == null || getAdapter() == null || getAdapter().getCount() == 0) { return false; } return super.onInterceptTouchEvent(event); } catch (RuntimeException e) { Log.e(TAG, "Exception during WrapContentViewPager onTouchEvent: " + "index out of bound, or nullpointer even if we check the adapter before " + e.toString()); return false; } }
From source file:com.github.omadahealth.circularbarpager.library.viewpager.WrapContentViewPager.java
/** * Fixes for "java.lang.IndexOutOfBoundsException Invalid index 0, size is 0" * on "android.support.v4.view.ViewPager.performDrag" *//*from ww w . java 2s.c om*/ @Override public boolean onTouchEvent(MotionEvent ev) { try { if (ev == null || getAdapter() == null || getAdapter().getCount() == 0) { return false; } return super.onTouchEvent(ev); } catch (RuntimeException e) { Log.e(TAG, "Exception during WrapContentViewPager onTouchEvent: " + "index out of bound, or nullpointer even if we check the adapter before " + e.toString()); return false; } }
From source file:com.cloudbees.demo.beesshop.web.ProductController.java
@RequestMapping(value = "/product/{id}/edit-form", method = RequestMethod.GET) public String displayEditForm(@PathVariable long id, Model model) { Product product = productRepository.get(id); if (product == null) { throw new ProductNotFoundException(id); }// w ww .j av a2 s . c o m model.addAttribute(product); try { fileStorageService.checkConfiguration(); } catch (RuntimeException e) { model.addAttribute("amazonS3FileStorageServiceFailure", e.toString()); } return "product/edit-form"; }
From source file:org.lsc.utils.GroovyEvaluator.java
/** * Local instance evaluation.//from w w w . ja v a2 s. com * * @param expression * the expression to eval * @param params * the keys are the name used in the * @return the evaluation result */ private Object instanceEval(final Task task, final String expression, final Map<String, Object> params) { Bindings bindings = engine.createBindings(); /* Allow to have shorter names for function in the package org.lsc.utils.directory */ String expressionImport = // "import static org.lsc.utils.directory.*\n" + // "import static org.lsc.utils.*\n" + expression; // add LDAP interface for destination if (!bindings.containsKey("ldap") && task.getDestinationService() instanceof AbstractSimpleJndiService) { ScriptableJndiServices dstSjs = new ScriptableJndiServices(); dstSjs.setJndiServices(((AbstractSimpleJndiService) task.getDestinationService()).getJndiServices()); bindings.put("ldap", dstSjs); } // add LDAP interface for source if (!bindings.containsKey("srcLdap") && task.getSourceService() instanceof AbstractSimpleJndiService) { ScriptableJndiServices srcSjs = new ScriptableJndiServices(); srcSjs.setJndiServices(((AbstractSimpleJndiService) task.getSourceService()).getJndiServices()); bindings.put("srcLdap", srcSjs); } if (params != null) { for (String paramName : params.keySet()) { bindings.put(paramName, params.get(paramName)); } } Object ret = null; try { if (task.getScriptIncludes() != null) { for (File scriptInclude : task.getScriptIncludes()) { String extension = FilenameUtils.getExtension(scriptInclude.getAbsolutePath()); if ("groovy".equals(extension) || "gvy".equals(extension) || "gy".equals(extension) || "gsh".equals(extension)) { FileReader reader = new FileReader(scriptInclude); try { engine.eval(reader, bindings); } finally { reader.close(); } } } } ret = engine.eval(expressionImport, bindings); } catch (RuntimeException e) { throw e; } catch (Exception e) { LOGGER.error(e.toString()); LOGGER.debug(e.toString(), e); return null; } return ret; }
From source file:org.cloudsimulator.controller.ServiceMetricController.java
public String createServiceMetric() { XmlRdfCreator xmlRdfCreator = new XmlRdfCreator(); Random random = new Random(); createdXmlRdfServiceMetric = ""; this.okXmlRdf = false; for (GroupServiceMetric groupServiceMetric : groupServiceMetricList) { try {/* w w w . j a va 2s . c o m*/ Date dateFrom = new SimpleDateFormat(DATEFORMAT).parse(groupServiceMetric.getDateFrom() + ":00"); Date dateTo = new SimpleDateFormat(DATEFORMAT).parse(groupServiceMetric.getDateTo() + ":00"); Long period = (dateTo.getTime() - dateFrom.getTime()) / (groupServiceMetric.getNumberServiceMetric() + 1); Date currentDate = dateFrom; for (int i = 0; i < groupServiceMetric.getNumberServiceMetric(); i++) { currentDate = new Date(currentDate.getTime() + period); if ("".equals(createdXmlRdfServiceMetric)) { createdXmlRdfServiceMetric = xmlRdfCreator.createServiceMetricXmlRdf(new ServiceMetric( Utility.convertDateToString(DATEFORMAT, currentDate), groupServiceMetric.getMetricName(), random.nextFloat() * (groupServiceMetric.getMaxValue() - groupServiceMetric.getMinValue()) + groupServiceMetric.getMinValue(), groupServiceMetric.getMetricUnit(), groupServiceMetric.getDependsOn())); } else { createdXmlRdfServiceMetric = new StringBuilder(createdXmlRdfServiceMetric).insert( createdXmlRdfServiceMetric.length() - 12, xmlRdfCreator.createServiceMetricXmlRdfWithoutRDFElement(new ServiceMetric( Utility.convertDateToString(DATEFORMAT, currentDate), groupServiceMetric.getMetricName(), random.nextFloat() * (groupServiceMetric.getMaxValue() - groupServiceMetric.getMinValue()) + groupServiceMetric.getMinValue(), groupServiceMetric.getMetricUnit(), groupServiceMetric.getDependsOn()))) .toString(); } } createdXmlRdfServiceMetric = new StringBuilder(createdXmlRdfServiceMetric) .insert(createdXmlRdfServiceMetric.length() - 12, xmlRdfCreator.createServiceMetricXmlRdfWithoutRDFElement(new ServiceMetric( Utility.convertDateToString(DATEFORMAT, new Date(currentDate.getTime() + period)), groupServiceMetric.getMetricName(), groupServiceMetric.getFinalValue(), groupServiceMetric.getMetricUnit(), groupServiceMetric.getDependsOn()))) .toString(); } catch (RuntimeException e) { LOGGER.error(e.getMessage(), e); this.errorMessage = e.toString(); } catch (Exception e) { LOGGER.error(e.getMessage(), e); this.errorMessage = e.toString(); } } this.okXmlRdf = true; return "visualizeXMLServiceMetric"; }