List of usage examples for org.apache.commons.lang3.exception ContextedRuntimeException ContextedRuntimeException
public ContextedRuntimeException(final String message, final Throwable cause)
From source file:com.rodaxsoft.junit.mailgun.MemberDetailsConverter.java
@Override public <T> T convert(Class<T> type, Object value) { MemberDetails details = null;/* ww w . j a va 2s.com*/ if (value instanceof JSONObject) { JSONObject obj = (JSONObject) value; details = new MemberDetails(); try { BeanUtils.populate(details, obj); } catch (IllegalAccessException | InvocationTargetException e) { ContextedRuntimeException cre; cre = new ContextedRuntimeException("Bean population error", e); cre.addContextValue("value", obj); throw cre; } } return type.cast(details); }
From source file:com.anrisoftware.prefdialog.appdialogs.dialogheader.HeaderLogoLogger.java
RuntimeException errorScaleImage(HeaderLogo header, Exception e) {
return logException(new ContextedRuntimeException(error_scale_header_logo_image.toString(), e),
error_scale_header_logo_image_message.toString(), e.getLocalizedMessage());
}
From source file:com.codspire.mojo.artifactlookup.LookupForDependency.java
public LookupForDependency(File artifactLocation, boolean recursive, List<String> remoteArtifactRepositoriesURL, File outputDirectory, Log log) { try {/*from w w w . j a v a 2 s. c o m*/ this.plugInConfig = new PropertiesConfiguration("artifact-lookup-maven-plugin.properties"); this.plugInConfig.setListDelimiter(','); } catch (ConfigurationException e) { throw new ContextedRuntimeException("Unable to load artifact-lookup-maven-plugin.properties", e); } this.log = log; this.outputDirectory = outputDirectory; this.remoteArtifactRepositoriesURL = remoteArtifactRepositoriesURL; this.notFoundList = loadArtifacts(artifactLocation, recursive); this.foundList = new ArrayList<ProcessingStatus>(); }
From source file:com.wolvereness.bluebutton.Version.java
/** * @param properties The properties to load from * @throws UnsupportedEncodingException If UTF8 isn't supported *///w w w .ja v a 2 s . c o m public Version(final Properties properties) throws UnsupportedEncodingException { try { this.branch = getProperty(properties, "git.branch"); this.buildTime = getProperty(properties, "git.build.time"); this.buildUserEmail = getProperty(properties, "git.build.user.email"); this.buildUserName = getProperty(properties, "git.build.user.name"); this.commitId = getProperty(properties, "git.commit.id"); this.commitMessageFull = getProperty(properties, "git.commit.message.full"); this.commitMessageShort = getProperty(properties, "git.commit.message.short"); this.commitTime = getProperty(properties, "git.commit.time"); this.commitUserEmail = getProperty(properties, "git.commit.user.email"); this.commitUserName = getProperty(properties, "git.commit.user.name"); this.describe = getProperty(properties, "git.commit.id.describe"); } catch (final Throwable t) { final ContextedRuntimeException ex = new ContextedRuntimeException("Failed to read properties", t); for (final Entry<Object, Object> entry : properties.entrySet()) { ex.addContextValue(entry.getKey() == null ? null : entry.getKey().toString(), entry.getValue()); } throw ex; } }
From source file:com.codspire.mojo.artifactlookup.ProcessResponse.java
/** * /*from w w w.ja v a 2 s . co m*/ * @param sha1Checksum * @return */ public GAV lookupRepo(String sha1Checksum) { String url = apiEndpoint + sha1Checksum; log.debug("Request URL: " + url); HttpGet httpGet = new HttpGet(url); ResponseHandler<String> responseHandler = new ResponseHandler<String>() { public String handleResponse(final HttpResponse response) throws ClientProtocolException, IOException { int status = response.getStatusLine().getStatusCode(); if (status >= 200 && status < 300) { HttpEntity entity = response.getEntity(); return entity != null ? EntityUtils.toString(entity) : null; } else { throw new ClientProtocolException("Unexpected response status: " + status); } } }; String responseBody = null; GAV gav; try (CloseableHttpClient httpclient = HttpClients.createDefault()) { responseBody = httpclient.execute(httpGet, responseHandler); if (log.isDebugEnabled()) { log.debug("----------------------------------------"); log.debug(responseBody); log.debug("----------------------------------------"); } gav = getGAV(responseBody); if (log.isDebugEnabled()) { log.debug(gav.toString()); } } catch (Exception e) { throw new ContextedRuntimeException("Unable to get the http response: " + url, e); } if (gav == null || gav.isIncomlete()) { throw new ContextedRuntimeException("No GAV found for " + sha1Checksum); } return gav; }
From source file:com.rodaxsoft.mailgun.MailgunManager.java
private static void loadProperties() { if (hasProperties()) { LOG.info("Loading mailgun properties..."); FileBasedConfigurationBuilder<PropertiesConfiguration> builder; final Class<PropertiesConfiguration> propClazz = PropertiesConfiguration.class; builder = new FileBasedConfigurationBuilder<PropertiesConfiguration>(propClazz); Parameters params = new Parameters(); final File file = new File(MAILGUN_PROPERTIES); builder.configure(params.fileBased().setFile(file)); PropertiesConfiguration config;//w w w . ja v a 2 s. c om try { config = builder.getConfiguration(); DynaBean bean = new ConfigurationDynaBean(config); sMailgunAccount = new MailgunAccount(bean); } catch (ConfigurationException e) { throw new ContextedRuntimeException("Error loading mailgun.properties", e); } } else { LOG.warn("No `mailgun.properties` in CLASSPATH"); } }
From source file:org.force66.beantester.testbeans.BaseBean.java
@Override public Object clone() throws CloneNotSupportedException { CallingRegistry.addCall("clone"); try {//from ww w. jav a2 s .c o m return BeanUtils.cloneBean(this); } catch (Exception e) { throw new ContextedRuntimeException("Error cloning value object", e).addContextValue("class", this.getClass().getName()); } }
From source file:org.force66.cxfutils.reflect.ReflectUtils.java
protected static Object readField(final Field field, final Object target) { try {//from www.j av a 2 s .com return FieldUtils.readField(field, target, true); } catch (Exception e) { throw new ContextedRuntimeException("Error reading field", e).addContextValue("field", field) .addContextValue("object", target); } }
From source file:org.force66.cxfutils.reflect.ReflectUtils.java
public static Object safeInvokeExactMethod(final Object object, final String methodName, Object... args) { try {//from w w w. ja va 2s. c o m return MethodUtils.invokeExactMethod(object, methodName, args); } catch (Exception e) { ContextedRuntimeException ce = new ContextedRuntimeException("Error invoking method", e) .addContextValue("methodName", methodName).addContextValue("object", object); if (args != null) { for (int offset = 0; offset < args.length; offset++) { ce.addContextValue("arg " + offset, args[offset]); } } throw ce; } }