List of usage examples for java.lang Error Error
public Error(Throwable cause)
From source file:hr.fer.zemris.vhdllab.platform.ui.command.DevCreateUncaughtErrorCommand.java
@Override protected void doExecuteCommand() { throw new Error("Forced unchaught error"); }
From source file:Main.java
public static String toString(final Document document) { try {// w w w . j a v a 2 s. com final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final TransformerFactory tf = TransformerFactory.newInstance(); final Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.STANDALONE, "yes"); //http://johnsonsolutions.blogspot.ca/2007/08/xml-transformer-indent-doesnt-work-with.html transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); transformer.transform(new DOMSource(document), new StreamResult(baos)); final String result = baos.toString(); return result; } catch (final TransformerException e) { throw new Error(e); } }
From source file:com.orange.ngsi2.model.ErrorTest.java
@Test public void checkSerialization() throws JsonProcessingException { ObjectMapper objectMapper = new ObjectMapper().registerModule(new Jdk8Module()); Error parseError = new Error("400"); String json = objectMapper.writeValueAsString(parseError); assertTrue(json.contains("error")); assertFalse(json.contains("description")); assertFalse(json.contains("affectedItems")); }
From source file:com.peanuts.database.DatabaseFactory.java
public static void init(String filename) { if (dataSource != null) { return;//w ww. ja va 2 s. c om } JDBCConfig.init(filename); try { java.lang.Class.forName(JDBCConfig.JDBC_DRIVER).newInstance(); } catch (Exception e) { log.fatal("Error obtaining DB driver", e); throw new Error("DB Driver doesnt exist!"); } connectionPool = new GenericObjectPool(); connectionPool.setMaxIdle(JDBCConfig.JDBC_CONNECTION_MIN); connectionPool.setMaxActive(JDBCConfig.JDBC_CONNECTION_MAX); try { dataSource = setupDataSource(); Connection c = dataSource.getConnection(); /** On verifie que la connection fonctionne bien **/ c.close(); } catch (Exception e) { log.fatal("Error with mysql connection to : " + JDBCConfig.JDBC_URL + " | user : " + JDBCConfig.JDBC_USER + " | password :" + JDBCConfig.JDBC_PASSWORD); throw new Error("Database mysql not initialized!"); } log.info("Successfully connected to database and pool initialization"); }
From source file:com.examples.with.different.packagename.concolic.Tracer.java
/** * Used when a serious error has occured, from which recovery is not * foreseen. Will throw an Error with the given message, as well as issue a * trace with level Tracer.ERROR./*w ww. j a v a 2 s .c o m*/ * * @param trace * the string to display. * @exception Error * always thrown. * @deprecated */ public static void error(String trace) throws Error { log.error(trace); throw new Error(trace); }
From source file:Service.FichierServiceImpl.java
private static String hashNomFichier(String nomFichier) { byte[] uniqueKey = nomFichier.getBytes(); byte[] hash = null; try {//from w w w . j a v a 2 s .c o m hash = MessageDigest.getInstance("MD5").digest(uniqueKey); } catch (NoSuchAlgorithmException e) { throw new Error("No MD5 support in this VM."); } StringBuilder hashString = new StringBuilder(); for (int i = 0; i < hash.length; i++) { String hex = Integer.toHexString(hash[i]); if (hex.length() == 1) { hashString.append('0'); hashString.append(hex.charAt(hex.length() - 1)); } else { hashString.append(hex.substring(hex.length() - 2)); } } return hashString.toString(); }
From source file:net.mikaboshi.intra_mart.tools.log_stats.Application.java
private Application() { InputStream inStream = null;//w w w .jav a 2s .c om try { inStream = this.getClass().getResourceAsStream("im-log-stats.properties"); this.config.load(inStream); } catch (IOException e) { throw new Error(e); } finally { IOUtils.closeQuietly(inStream); } }
From source file:dlauncher.modpacks.packs.VanillaModPackVersion.java
public VanillaModPackVersion(JSONObject jsonObject, ModPack main) { this.main = main; this.branch = jsonObject.getString("type"); this.version = jsonObject.getString("id"); try {/*from w ww . j a va2 s . c om*/ this.releaseDate = dateFormat.parse(jsonObject.getString("releaseTime")).getTime(); } catch (ParseException ex) { throw new Error(ex); } this.installedSize = -1; this.downloads = Collections.emptyList(); }
From source file:it.cavallefano.abstractfactoryspring.factory.ObjFactory.java
@Override public void setApplicationContext(ApplicationContext ac) throws BeansException { mApplicationContext = ac;//from w ww . j ava 2 s . co m Map<String, Car> processorMap = mApplicationContext.getBeansOfType(Car.class); if (processorMap.isEmpty()) { Error noProcessorError = new Error("No Car configured. Check Spring Context"); throw noProcessorError; } Set<Entry<String, Car>> processorEntrySet = processorMap.entrySet(); Iterator<Entry<String, Car>> iterator = processorEntrySet.iterator(); while (iterator.hasNext()) { Entry<String, Car> entry = iterator.next(); processorBeanMap.put(entry.getValue().getClass().getSimpleName(), entry.getKey()); } }
From source file:io.servicecomb.swagger.generator.core.unittest.UnitTestSwaggerUtils.java
public static String pretty(Swagger swagger) { try {// w ww . j a v a 2 s. c o m return writer.writeValueAsString(swagger); } catch (JsonProcessingException e) { throw new Error(e); } }