List of usage examples for java.lang Error Error
public Error(Throwable cause)
From source file:com.genentech.chemistry.tool.mm.SDFMMMinimize.java
private static MMMinMethod getMinMethodFromName(String requestedProgram) { if (minMethodNameObjectMap.containsKey(requestedProgram)) { return minMethodNameObjectMap.get(requestedProgram); }/*from w w w . ja v a2s . co m*/ { throw new Error("Minimization method not available." + requestedProgram); } }
From source file:com.google.walkaround.wave.server.attachment.AttachmentMetadata.java
private ImageMetadata createImageMetadata(String key) { final JSONObject imgData; try {/*from ww w . j a v a2 s . c o m*/ imgData = getMetadata().has(key) ? getMetadata().getJSONObject(key) : null; } catch (JSONException e) { throw new Error(e); } if (imgData == null) { return null; } return new ImageMetadata() { @Override public int getWidth() { try { return imgData.getInt("width"); } catch (JSONException e) { throw new RuntimeException(e); } } @Override public int getHeight() { try { return imgData.getInt("height"); } catch (JSONException e) { throw new RuntimeException(e); } } }; }
From source file:lv.semti.morphology.analyzer.Word.java
public Word(Node node) { if (node.getNodeName().equalsIgnoreCase("V?rds")) { NodeList nodes = node.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node n = nodes.item(i); if (n.getNodeName().equalsIgnoreCase("V?rdforma")) wordforms.add(new Wordform(n)); }//ww w . j av a 2 s.c o m Node n = node.getAttributes().getNamedItem("v?rds"); if (n != null) token = n.getTextContent(); n = node.getAttributes().getNamedItem("pareiz?V?rdforma"); if (n != null) setCorrectWordform(wordforms.get(Integer.parseInt(n.getTextContent()))); } else if (node.getNodeName().equalsIgnoreCase("V?rdforma")) { token = node.getAttributes().getNamedItem("v?rds").getTextContent(); wordforms.add(new Wordform(node)); } else throw new Error("Node " + node.getNodeName() + " nav ne V?rds, ne V?rdforma"); }
From source file:ControlQueryPApplet.java
/*************************************************************************** * Initialise the applet by attempting to create and start a Player object * capable of playing the media specified in the applet tag. **************************************************************************/ public void init() { setLayout(new BorderLayout()); setBackground(Color.lightGray); try {/* w ww . ja v a 2 s . co m*/ nameOfMedia2Play = (new URL(getDocumentBase(), getParameter(MEDIA_NAME_PROPERTY))).toExternalForm(); locator = new MediaLocator(nameOfMedia2Play); Manager.setHint(Manager.PLUGIN_PLAYER, new Boolean(true)); player = Manager.createPlayer(locator); player.addControllerListener(this); timer = new SystemTimeBase(); player.start(); } catch (Exception e) { throw new Error("Couldn't initialise BBPApplet: " + e.getMessage()); } }
From source file:com.tera.common.database.factory.AbstractDatabaseFactory.java
/** * @param dbConfig/*from www .j a v a 2s. c o m*/ * @throws Error */ void createConnectionPool(DatabaseConfiguration dbConfig) throws Error { log.info("Creating DB pool"); connectionPool = new GenericObjectPool(); connectionPool.setMaxIdle(dbConfig.getConnectionsIdelMax()); connectionPool.setMinIdle(dbConfig.getConnectionsIdleMin()); connectionPool.setMaxActive(dbConfig.getConnectionsActiveMax()); connectionPool.setTestOnBorrow(true); try { dataSource = setupDataSource(dbConfig); Connection c = getConnection(); DatabaseMetaData dmd = c.getMetaData(); databaseName = dmd.getDatabaseProductName(); databaseMajorVersion = dmd.getDatabaseMajorVersion(); databaseMinorVersion = dmd.getDatabaseMinorVersion(); c.close(); } catch (Exception e) { log.error("Error with connection string: {}", dbConfig, e); throw new Error("DatabaseFactory not initialized!"); } log.info("Successfully connected to the database"); }
From source file:com.appeligo.channelfeed.CaptureApp.java
/** * @param args//from w w w. j av a 2 s . c o m * @param defaultConfigFile * @throws ConfigurationException */ public CaptureApp(String[] args, String defaultConfigFile) { try { // Set up a simple configuration that logs on the console. PatternLayout pattern = new PatternLayout("%d{ISO8601} %-5p [%-c{1} - %t] - %m%n"); BasicConfigurator.configure(new ConsoleAppender(pattern)); configFile = defaultConfigFile; if (args.length > 0) { if (args.length == 2 && args[0].equals("-config")) { configFile = args[1]; } else { log.error("Usage: java " + getClass().getName() + " [-config <xmlfile>]"); throw new Error("Cannot continue"); } } config = new XMLConfiguration(configFile); configureLogging(config, pattern); String documentRoot = config.getString("documentRoot[@path]"); log.info("documentRoot = " + documentRoot); if (documentRoot == null) { log.error("Document root is not set (typically it is \"/var/flip.tv\")"); throw new Error("Cannot continue"); } else { documentRoot.trim(); if (!documentRoot.endsWith("/")) { documentRoot += "/"; } } captionDocumentRoot = documentRoot + "captiondb"; previewDocumentRoot = documentRoot + "previews"; String epgServer = config.getString("epgServer[@url]"); log.info("epgServer = " + epgServer); connectToEPG(epgServer); writing = config.getBoolean("writing", true); log.info("writing = " + writing); int destinationsCount = config.getList("destinations.destination[@url]").size(); destinationURLs = new String[destinationsCount]; destinationRaws = new boolean[destinationsCount]; for (int i = 0; i < destinationsCount; i++) { Configuration destination = config.subset("destinations.destination(" + i + ")"); destinationURLs[i] = destination.getString("[@url]"); destinationRaws[i] = destination.getBoolean("[@raw]", false); log.info("destination " + i + " = " + destinationURLs[i] + ", raw=" + destinationRaws[i]); } final String captionPort = config.getString("captionPort[@number]"); log.info("captionPort = " + captionPort); if (captionPort != null) { catchCaptions(captionPort); } int providerCount = config.getList("providers.provider.headend").size(); for (int i = 0; i < providerCount; i++) { Configuration provider = config.subset("providers.provider(" + i + ")"); headend = provider.getString("headend"); lineupDevice = provider.getString("lineupDevice"); frequencyStandard = FrequencyStandard.valueOf(provider.getString("frequencyStandard")); log.info(identifyMe()); if (headend == null || lineupDevice == null || frequencyStandard == null) { log.error("Invalid configuration in: " + identifyMe()); throw new Error("Cannot continue"); } openSources(provider); } } catch (ConfigurationException e) { log.error("Configuration error in file " + configFile, e); throw new Error("Cannot continue"); } catch (Throwable e) { log.error("Unexpected Exception", e); throw new Error("Cannot continue"); } }
From source file:com.termmed.utils.ResourceUtils.java
/** * Gets the resources from directory./*from w w w . j a v a2s. c o m*/ * * @param directory the directory * @param pattern the pattern * @return the resources from directory */ private static Collection<String> getResourcesFromDirectory(final File directory, final Pattern pattern) { final ArrayList<String> retval = new ArrayList<String>(); final File[] fileList = directory.listFiles(); for (final File file : fileList) { if (file.isDirectory()) { retval.addAll(getResourcesFromDirectory(file, pattern)); } else { try { final String fileName = file.getCanonicalPath(); final boolean accept = pattern.matcher(fileName).matches(); if (accept) { retval.add(fileName); } } catch (final IOException e) { throw new Error(e); } } } return retval; }
From source file:EmailNotificationTest.java
public void setMailMock() { // setup mail sender mock invocations reset(this.javaMailSender); when(this.javaMailSender.createMimeMessage()).thenCallRealMethod(); Answer dumpMessage = new Answer() { @Override//from ww w . j a v a 2 s.c om public Object answer(InvocationOnMock invocation) throws Throwable { Object arg = invocation.getArguments()[0]; if (arg instanceof MimeMessage) { MimeMessage m = (MimeMessage) arg; System.out.println("EMAIL DUMP:"); m.writeTo(System.out); } else if (arg instanceof SimpleMailMessage) { SimpleMailMessage m = (SimpleMailMessage) arg; System.out.println("EMAIL DUMP:"); System.out.println(m.toString()); } else { throw new Error("Could not print email: " + arg); } return null; } }; doAnswer(dumpMessage).when(this.javaMailSender).send(any(MimeMessage.class)); doAnswer(dumpMessage).when(this.javaMailSender).send(any(SimpleMailMessage.class)); }
From source file:net.sourceforge.jabm.learning.QLearner.java
public Object protoClone() { try {//from ww w. j a v a 2 s .c om QLearner cloned = (QLearner) clone(); return cloned; } catch (CloneNotSupportedException e) { logger.error(e.getMessage()); throw new Error(e); } }
From source file:com.laxser.blitz.lama.core.SelectOperation.java
@Override public Object execute(Map<String, Object> parameters) { // /*from w w w. j a v a 2 s.co m*/ List<?> listResult = dataAccess.select(sql, modifier, parameters, rowMapper); final int sizeResult = listResult.size(); // Result ? if (returnType.isAssignableFrom(List.class)) { // List ? return listResult; } else if (returnType.isArray() && byte[].class != returnType) { Object array = Array.newInstance(returnType.getComponentType(), sizeResult); if (returnType.getComponentType().isPrimitive()) { int len = listResult.size(); for (int i = 0; i < len; i++) { Array.set(array, i, listResult.get(i)); } } else { listResult.toArray((Object[]) array); } return array; } else if (Map.class.isAssignableFrom(returnType)) { // KeyValuePair ?? Map // entry.key?nullHashMap Map<Object, Object> map; if (returnType.isAssignableFrom(HashMap.class)) { map = new HashMap<Object, Object>(listResult.size() * 2); } else if (returnType.isAssignableFrom(Hashtable.class)) { map = new Hashtable<Object, Object>(listResult.size() * 2); } else { throw new Error(returnType.toString()); } for (Object obj : listResult) { if (obj == null) { continue; } Map.Entry<?, ?> entry = (Map.Entry<?, ?>) obj; if (map.getClass() == Hashtable.class && entry.getKey() == null) { continue; } map.put(entry.getKey(), entry.getValue()); } return map; } else if (returnType.isAssignableFrom(HashSet.class)) { // Set ? return new HashSet<Object>(listResult); } else { if (sizeResult == 1) { // ? Bean?Boolean return listResult.get(0); } else if (sizeResult == 0) { // null if (returnType.isPrimitive()) { String msg = "Incorrect result size: expected 1, actual " + sizeResult + ": " + modifier.toString(); throw new EmptyResultDataAccessException(msg, 1); } else { return null; } } else { // IncorrectResultSizeDataAccessException String msg = "Incorrect result size: expected 0 or 1, actual " + sizeResult + ": " + modifier.toString(); throw new IncorrectResultSizeDataAccessException(msg, 1, sizeResult); } } }