List of usage examples for java.lang Error getMessage
public String getMessage()
From source file:no.digipost.api.useragreements.client.UnexpectedResponseException.java
public UnexpectedResponseException(final StatusLine status, final Error error) { this(status, error.getCode(), error.getMessage()); }
From source file:org.cloudata.core.common.util.ByteCodeClassLoader.java
@Override public Class<?> findClass(String name) throws ClassNotFoundException { try {/*w w w.j av a 2 s.co m*/ byte[] byteClass = null; synchronized (classes) { VersionedClass vClass = classes.get(name); if (vClass != null) { byteClass = vClass.classBytes; } else { } } if (byteClass == null) { return null; } Class<?> clazz = defineClass(name, byteClass, 0, byteClass.length); return clazz; } catch (Error e) { LOG.error("Class load error:" + e.getMessage(), e); return super.findSystemClass(name); } }
From source file:org.mule.config.builders.DeployableMuleXmlContextListener.java
public void initialize(ServletContext context) { String config = context.getInitParameter(MuleXmlBuilderContextListener.INIT_PARAMETER_MULE_CONFIG); if (config == null) { config = MuleServer.DEFAULT_CONFIGURATION; if (logger.isDebugEnabled()) { logger.debug("No Mule config file(s) specified, using default: " + config); }/*from w w w. j a v a 2 s .c o m*/ } else { if (logger.isDebugEnabled()) { logger.debug("Mule config file(s): " + config); } } if (muleContext == null) { throw new RuntimeException("MuleContext is not available"); } try { configurationBuilder = new WebappMuleXmlConfigurationBuilder(context, config); configurationBuilder.setUseDefaultConfigResource(false); // Support Spring-first configuration in webapps final ApplicationContext parentContext = (ApplicationContext) context .getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); if (parentContext != null) { configurationBuilder.setParentContext(parentContext); } configurationBuilder.configure(muleContext); } catch (MuleException ex) { context.log(ex.getMessage(), ex); // Logging is not configured OOTB for Tomcat, so we'd better make a // start-up failure plain to see. ex.printStackTrace(); } catch (Error error) { // WSAD doesn't always report the java.lang.Error, log it context.log(error.getMessage(), error); // Logging is not configured OOTB for Tomcat, so we'd better make a // start-up failure plain to see. error.printStackTrace(); throw error; } }
From source file:org.kerf.bgg.command.Command.java
@SuppressWarnings("unchecked") public <T> T execute() throws CommandExecutionException { try {/*from w w w. j av a 2 s.c o m*/ String commandLocation = API_URL + URLEncoder.encode(command + "?" + addProperties()); logger.debug("Command URL: " + commandLocation); URL commandUrl = new URL(commandLocation); URLConnection connection = commandUrl.openConnection(); if (connection instanceof HttpURLConnection) { HttpURLConnection httpConnection = null; int responseCode = 0; do { httpConnection = (HttpURLConnection) commandUrl.openConnection(); responseCode = httpConnection.getResponseCode(); logger.debug("Response: " + responseCode + ": " + httpConnection.getResponseMessage()); Thread.sleep(5000); } while (responseCode == 202); } String xml = IOUtils.toString(connection.getInputStream()); JAXBContext context = JAXBContext.newInstance(getReturnType(), org.kerf.bgg.jaxb.Error.class); Unmarshaller unmarshaller = context.createUnmarshaller(); logger.debug("RESULT: " + xml); Object result = unmarshaller.unmarshal(new StringReader(xml)); if (result instanceof org.kerf.bgg.jaxb.Error) { org.kerf.bgg.jaxb.Error error = (org.kerf.bgg.jaxb.Error) result; throw new CommandExecutionException(error.getMessage()); } else { return (T) result; // This is an unchecked cast, but an error would // have been thrown while unmarshalling if it was // illegal } } catch (Exception e) { logger.error(e.getMessage()); throw new CommandExecutionException("There was an issue executing the command", e); } }
From source file:org.apache.cocoon.template.instruction.Call.java
/** * @param executionContext//w ww.j av a 2 s . c o m * @throws SAXParseException */ private Define resolveMacroDefinition(ExpressionContext expressionContext, ExecutionContext executionContext) throws SAXParseException { if (this.macro instanceof Define) return (Define) macro; Object macroName; Object namespace; JXTExpression macroNameExpression = (JXTExpression) macro; try { macroName = macroNameExpression.getValue(expressionContext); namespace = targetNamespace.getValue(expressionContext); if (namespace == null) namespace = ""; } catch (Exception e) { throw new SAXParseException(e.getMessage(), getLocation(), e); } catch (Error err) { throw new SAXParseException(err.getMessage(), getLocation(), new ErrorHolder(err)); } Define definition = (Define) executionContext.getDefinitions() .get("{" + namespace.toString() + "}" + macroName.toString()); if (definition == null) throw new SAXParseException("no macro definition: " + macroName, getLocation()); return definition; }
From source file:org.overlord.gadgets.web.server.ShindigGadgetMetadataService.java
/** * Gets the gadget meta-data as a JSON object (from the shindig meta-data service). * @param gadgetUrl//from w ww . ja v a 2 s . com * @throws JSONException */ private MetadataResponse getMetaDataFromShindig(String gadgetUrl) throws JSONException { JSONObject params = new JSONObject().put("container", "default").put("view", "home").put("st", "default") .put("debug", true).append("ids", gadgetUrl).append("fields", "iframeUrl") .append("fields", "modulePrefs.*").append("fields", "needsTokenRefresh") .append("fields", "userPrefs.*").append("fields", "views.preferredHeight") .append("fields", "views.preferredWidth").append("fields", "expireTimeMs") .append("fields", "responseTimeMs").put("userId", "@viewer").put("groupId", "@self"); AnonymousSecurityToken securityToken = new AnonymousSecurityToken(); BaseRequestItem request = new BaseRequestItem(params, new HashMap<String, FormDataItem>(), securityToken, this.jsonConverter, (BeanJsonConverter) this.jsonConverter); Map<String, BaseResponse> responses = this.gadgetsHandler.metadata(request); BaseResponse response = responses.get(gadgetUrl); if (response instanceof MetadataResponse) { return (MetadataResponse) response; } else { Error error = response.getError(); if (error != null) { throw new JSONException(error.getMessage()); } else { throw new JSONException("Unknown error:" + response.getUrl()); } } }
From source file:org.mule.config.builders.MuleXmlBuilderContextListener.java
public void initialize(ServletContext context) { String config = context.getInitParameter(INIT_PARAMETER_MULE_CONFIG); if (config == null) { config = getDefaultConfigResource(); if (logger.isDebugEnabled()) { logger.debug("No Mule config file(s) specified, using default: " + config); }/*from w w w . ja v a2 s . c o m*/ } else { if (logger.isDebugEnabled()) { logger.debug("Mule config file(s): " + config); } } try { muleContext = createMuleContext(config, context); context.setAttribute(MuleProperties.MULE_CONTEXT_PROPERTY, muleContext); muleContext.start(); } catch (MuleException ex) { context.log(ex.getMessage(), ex); // Logging is not configured OOTB for Tomcat, so we'd better make a // start-up failure plain to see. ex.printStackTrace(); } catch (Error error) { // WSAD doesn't always report the java.lang.Error, log it context.log(error.getMessage(), error); // Logging is not configured OOTB for Tomcat, so we'd better make a // start-up failure plain to see. error.printStackTrace(); throw error; } }
From source file:io.dockstore.webservice.DockstoreWebserviceApplication.java
@Override public void initialize(Bootstrap<DockstoreWebserviceConfiguration> bootstrap) { // setup hibernate+postgres bootstrap.addBundle(hibernate);/*from ww w.ja v a 2 s . com*/ // serve static html as well bootstrap.addBundle(new AssetsBundle("/assets/", "/static/")); // enable views bootstrap.addBundle(new ViewBundle<>()); // for database migrations.xml bootstrap.addBundle(new MigrationsBundle<DockstoreWebserviceConfiguration>() { @Override public DataSourceFactory getDataSourceFactory(DockstoreWebserviceConfiguration configuration) { return configuration.getDataSourceFactory(); } }); if (cache == null) { int cacheSize = CACHE_IN_MB * BYTES_IN_KILOBYTE * KILOBYTES_IN_MEGABYTE; // 100 MiB final File tempDir; try { tempDir = Files.createTempDirectory("dockstore-web-cache-").toFile(); } catch (IOException e) { LOG.error("Could no create web cache"); throw new RuntimeException(e); } cache = new Cache(tempDir, cacheSize); } // match HttpURLConnection which does not have a timeout by default OkHttpClient okHttpClient = new OkHttpClient().newBuilder().cache(cache).connectTimeout(0, TimeUnit.SECONDS) .readTimeout(0, TimeUnit.SECONDS).writeTimeout(0, TimeUnit.SECONDS).build(); try { // this can only be called once per JVM, a factory exception is thrown in our tests URL.setURLStreamHandlerFactory(new OkUrlFactory(okHttpClient)); } catch (Error factoryException) { if (factoryException.getMessage().contains("factory already defined")) { LOG.info("OkHttpClient already registered, skipping"); } else { LOG.error("Could no create web cache, factory exception"); throw new RuntimeException(factoryException); } } }
From source file:io.servicecomb.serviceregistry.config.TestPropertiesLoader.java
@Test public void testCanNotAssignExtendedClass() { ConfigModel configModel = MicroserviceDefinition.createConfigModel("default", "invalidExtendedClass"); @SuppressWarnings("unchecked") Map<String, Object> desc = (Map<String, Object>) configModel.getConfig() .get(CONFIG_SERVICE_DESCRIPTION_KEY); desc.put("propertyExtentedClass", "java.lang.String"); MicroserviceDefinition microserviceDefinition = new MicroserviceDefinition(Arrays.asList(configModel)); try {//w w w. ja va2 s .c o m microserviceFactory.create(microserviceDefinition); Assert.fail("Must throw exception"); } catch (Error e) { Assert.assertEquals( "Define propertyExtendedClass java.lang.String in yaml, but not implement the interface PropertyExtended.", e.getMessage()); } }
From source file:org.apache.cocoon.template.instruction.FormatNumber.java
public Event execute(final XMLConsumer consumer, ExpressionContext expressionContext, ExecutionContext executionContext, MacroContext macroContext, Event startEvent, Event endEvent) throws SAXException { try {//ww w . j a v a2s.com String result = format(expressionContext); if (result != null) { char[] chars = result.toCharArray(); consumer.characters(chars, 0, chars.length); } } catch (Exception e) { throw new SAXParseException(e.getMessage(), getLocation(), e); } catch (Error err) { throw new SAXParseException(err.getMessage(), getLocation(), new ErrorHolder(err)); } return getNext(); }