List of usage examples for java.lang Exception getLocalizedMessage
public String getLocalizedMessage()
From source file:web.diva.server.model.profileplot.ProfilePlotImgeGenerator.java
public String toImage() { image = new BufferedImage(900, height, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = image.createGraphics(); graphics.setPaint(Color.WHITE); super.forceFullRepaint(graphics); // super.paint(graphics); byte[] imageData = null; try {//from w ww.jav a 2s . co m imageData = in.encode(image); } catch (Exception e) { System.out.println(e.getLocalizedMessage()); } String base64 = Base64.encodeBytes(imageData); base64 = "data:image/png;base64," + base64; return base64; }
From source file:com.marpies.ane.firebase.invites.functions.ShowInvitationDialogFunction.java
@Override public FREObject call(FREContext context, FREObject[] args) { super.call(context, args); String title = FREObjectUtils.getString(args[0]); String message = (args[1] != null) ? FREObjectUtils.getString(args[1]) : null; String deepLink = (args[2] != null) ? FREObjectUtils.getString(args[2]) : null; String imageURL = (args[3] != null) ? FREObjectUtils.getString(args[3]) : null; String callToActionText = (args[4] != null) ? FREObjectUtils.getString(args[4]) : null; String emailHtmlContent = (args[5] != null) ? FREObjectUtils.getString(args[5]) : null; String emailSubject = (args[6] != null) ? FREObjectUtils.getString(args[6]) : null; String googleAnalyticsTrackingId = (args[7] != null) ? FREObjectUtils.getString(args[7]) : null; String targetAndroidClientId = (args[8] != null) ? FREObjectUtils.getString(args[8]) : null; String targetIOSClientId = (args[9] != null) ? FREObjectUtils.getString(args[9]) : null; AppInviteInvitation.IntentBuilder inviteBuilder = new AppInviteInvitation.IntentBuilder(title); Intent inviteIntent;/*from ww w .ja v a 2 s . c om*/ if (message != null) { inviteBuilder.setMessage(message); } if (deepLink != null) { inviteBuilder.setDeepLink(Uri.parse(deepLink)); } if (imageURL != null) { inviteBuilder.setCustomImage(Uri.parse(imageURL)); } if (callToActionText != null) { inviteBuilder.setCallToActionText(callToActionText); } if (emailHtmlContent != null) { inviteBuilder.setEmailHtmlContent(emailHtmlContent); } if (emailSubject != null) { inviteBuilder.setEmailSubject(emailSubject); } if (googleAnalyticsTrackingId != null) { inviteBuilder.setGoogleAnalyticsTrackingId(googleAnalyticsTrackingId); } try { inviteIntent = inviteBuilder.build(); AIR.log("Invite intent built, opening dialog..."); AndroidActivityWrapper.GetAndroidActivityWrapper().addActivityResultListener(this); AIR.getContext().getActivity().startActivityForResult(inviteIntent, REQUEST_INVITE); } catch (Exception e) { /* Incorrect dialog data */ AIR.log("Invite intent creation failed: " + e.getLocalizedMessage()); AIR.dispatchEvent(FirebaseInvitesEvent.INVITE_ERROR, e.getLocalizedMessage()); } return null; }
From source file:edu.isi.misd.scanner.network.registry.web.controller.BaseController.java
@ExceptionHandler(ResourceNotFoundException.class) @ResponseBody//from w w w .j a va 2s . com @ResponseStatus(value = HttpStatus.NOT_FOUND) public ErrorMessage handleResourceNotFoundException(Exception e) { return new ErrorMessage(HttpStatus.NOT_FOUND.value(), HttpStatus.NOT_FOUND.getReasonPhrase(), e.getLocalizedMessage()); }
From source file:edu.isi.misd.scanner.network.registry.web.controller.BaseController.java
@ExceptionHandler(ForbiddenException.class) @ResponseBody/*w w w.j av a 2 s . c o m*/ @ResponseStatus(value = HttpStatus.FORBIDDEN) public ErrorMessage handleForbiddenException(Exception e) { return new ErrorMessage(HttpStatus.FORBIDDEN.value(), HttpStatus.FORBIDDEN.getReasonPhrase(), e.getLocalizedMessage()); }
From source file:com.amazonaws.mturk.cmd.GrantQualificationRequests.java
private void grantQualRequests(String[] qualReqs, Integer[] values) { // If we're not given anything, just no-op if (qualReqs == null) { return;/*w w w. ja va 2 s . c om*/ } checkIsUserCertain("You are about to grant " + qualReqs.length + " qual request(s)."); Integer value = null; for (int i = 0; qualReqs != null && i < qualReqs.length; i++) { try { if (values != null) value = values[i]; service.grantQualification(qualReqs[i], value); log.info("[" + qualReqs[i] + "] QualRequest successfully approved " + (value != null ? " with value (" + value + ")" : "")); } catch (Exception e) { log.error("Error granting qual request " + qualReqs[i] + " with value (" + value + "): " + e.getLocalizedMessage(), e); } } }
From source file:uk.ac.ebi.emma.controller.AlleleManagementListController.java
/** * Deletes the allele identified by <b>id</b>. This method is configured as * a GET because it is intended to be called as an ajax call. Using GET * avoids re-posting problems with the back button. NOTE: It is the caller's * responsibility to insure there are no foreign key constraints. * /* w ww . jav a2 s . com*/ * @param allele_key primary key of the allele to be deleted * @return a JSON string containing 'status' [ok or fail], and a message [ * empty string if status is ok; error message otherwise] */ @RequestMapping(value = "/deleteAllele", method = RequestMethod.GET) @ResponseBody public ResponseEntity<String> deleteAllele( @RequestParam(value = "allele_key", required = true) int allele_key) { String status, message; try { allelesManager.delete(allele_key); status = "ok"; message = ""; } catch (Exception e) { status = "fail"; message = e.getLocalizedMessage(); } JSONObject returnStatus = new JSONObject(); returnStatus.put("status", status); returnStatus.put("message", message); HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/json; charset=utf-8"); return new ResponseEntity(returnStatus.toJSONString(), headers, HttpStatus.OK); }
From source file:com.mission_base.arviewer_android.viewer.ArvosAugment.java
/** * Fills the properties of one augment by parsing a description in JSON * format downloaded from the web.// w w w.j a va 2s. c om * * @param input * The augment description in JSON format. * @return "OK" or "ER" followed by the error message. */ public String parse(String input) { try { JSONObject jsonAugment = new JSONObject(input); mName = jsonAugment.getString("name"); mAuthor = jsonAugment.has("author") ? jsonAugment.getString("author") : ""; mDescription = jsonAugment.has("description") ? jsonAugment.getString("description") : ""; JSONArray jsonPois = new JSONArray(jsonAugment.getString("pois")); if (jsonPois == null || jsonPois.length() == 0) { return "ERNo pois found in augment " + mName; } for (int i = 0; i < jsonPois.length(); i++) { JSONObject newPoi = jsonPois.getJSONObject(i); if (newPoi != null) { ArvosPoi poi = new ArvosPoi(this); poi.parse(newPoi); mPois.add(poi); } } } catch (Exception e) { return "ERJSON parse error. " + e.getLocalizedMessage(); } return "OK"; }
From source file:edu.isi.misd.scanner.network.registry.web.controller.BaseController.java
@ExceptionHandler({ BadRequestException.class, IllegalArgumentException.class, HttpMessageNotReadableException.class, TypeMismatchException.class }) @ResponseBody//from w ww . j a v a2 s. co m @ResponseStatus(value = HttpStatus.BAD_REQUEST) public ErrorMessage handleBadRequestException(Exception e) { return new ErrorMessage(HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), e.getLocalizedMessage()); }
From source file:it.geosolutions.geoserver.jms.JMSManager.java
/** * Method to make lookup using the type of the passed eventType. * /* ww w . java 2s. c om*/ * @param <S> * @param <O> * @param eventType * @return the handler * @throws IllegalArgumentException */ public <S extends Serializable, O> JMSEventHandler<S, O> getHandler(final O eventType) throws IllegalArgumentException { final Set<?> beanSet = beans.entrySet(); // declare a tree set to define the handler priority final Set<JMSEventHandlerSPI<S, O>> candidates = new TreeSet<JMSEventHandlerSPI<S, O>>( new Comparator<JMSEventHandlerSPI<S, O>>() { @Override public int compare(JMSEventHandlerSPI<S, O> o1, JMSEventHandlerSPI<S, O> o2) { if (o1.getPriority() < o2.getPriority()) return -1; else if (o1.getPriority() == o2.getPriority()) { return 0; // } else if (o1.getPriority()>o2.getPriority()){ } else { return 1; } } }); // for each handler check if it 'canHandle' the incoming object if so // add it to the tree for (final Iterator<?> it = beanSet.iterator(); it.hasNext();) { final Map.Entry<String, ?> entry = (Entry<String, ?>) it.next(); final JMSEventHandlerSPI<S, O> spi = (JMSEventHandlerSPI) entry.getValue(); if (spi != null) { if (spi.canHandle(eventType)) { if (LOGGER.isLoggable(Level.INFO)) LOGGER.info("Creating an instance of: " + spi.getClass()); candidates.add(spi); } } } // TODO return the entire tree leaving choice to the caller (useful to // build a failover list) // return the first available handler final Iterator<JMSEventHandlerSPI<S, O>> it = candidates.iterator(); while (it.hasNext()) { try { final JMSEventHandler<S, O> handler = it.next().createHandler(); if (handler != null) return handler; } catch (Exception e) { if (LOGGER.isLoggable(Level.WARNING)) LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); } } final String message = "Unable to find the needed Handler SPI for event of type: " + eventType.getClass().getCanonicalName(); if (LOGGER.isLoggable(Level.WARNING)) LOGGER.warning(message); throw new IllegalArgumentException(message); }
From source file:org.ameba.aop.ServiceLayerAspect.java
/** * Around intercepted methods do some logging and exception translation. <p> <ul> <li> Set log level of {@link * LoggingCategories#SERVICE_LAYER_ACCESS} to INFO to enable method tracing. <li>Set log level of {@link * LoggingCategories#SERVICE_LAYER_EXCEPTION} to ERROR to enable exception logging. </ul> </p> * * @param pjp The joinpoint//from www . jav a 2 s . co m * @return Method return value * @throws Throwable in case of errors */ @Around("org.ameba.aop.Pointcuts.servicePointcut()") public Object around(ProceedingJoinPoint pjp) throws Throwable { long startMillis = 0L; if (SRV_LOGGER.isDebugEnabled()) { SRV_LOGGER.debug("[S]>> Method call: {}", pjp.toShortString()); startMillis = System.currentTimeMillis(); } Object obj = null; try { obj = pjp.proceed(); } catch (Exception ex) { Exception e = translateException(ex); if (EXC_LOGGER.isErrorEnabled()) { EXC_LOGGER.error(e.getLocalizedMessage(), e); } throw e; } finally { if (SRV_LOGGER.isDebugEnabled()) { SRV_LOGGER.debug("[S]<< {} took {} [ms]", pjp.toShortString(), (System.currentTimeMillis() - startMillis)); } } return obj; }