List of usage examples for java.lang Exception Exception
public Exception(Throwable cause)
From source file:org.taverna.server.master.localworker.ConfigBean.java
@Bean(name = "localworker.factory") AbstractRemoteRunFactory getLocalworkerFactory(@Value("${backEndFactory}") String mode) throws Exception { AbstractRemoteRunFactory factory;/*from w w w.java2 s. com*/ if (mode == null) throw new Exception("no value for ${backEndFactory}"); if ("org.taverna.server.master.localworker.IdAwareForkRunFactory".equals(mode)) factory = new IdAwareForkRunFactory(); else if ("org.taverna.server.master.localworker.ForkRunFactory".equals(mode)) factory = new ForkRunFactory(); else throw new Exception("unknown remote run factory: " + mode); return factory; }
From source file:com.apress.prospringintegration.errorhandling.MockException.java
public String processMessage(String s) throws Exception { throw new Exception("Test"); }
From source file:org.qucosa.migration.routes.StagingRouteBuilder.java
static public String extractPID(HttpResponse httpResponse) throws Exception { Header locationHeader = httpResponse.getFirstHeader("Location"); if (locationHeader == null) { throw new Exception("No location header in HTTP response."); }/*w ww . ja va 2 s.c om*/ String locationStr = locationHeader.getValue(); return locationStr.substring(locationStr.lastIndexOf('/') + 1); }
From source file:core.SHA256Hash.java
public static String getHashAlgType(String url) throws Exception { if (url.contains(SHA256_16)) { return SHA256_16; }//from w w w. j ava 2 s . com if (url.contains(SHA256)) { return SHA256; } throw new Exception("Unknown hash alg type"); }
From source file:BareBonesBrowserLaunch.java
public static void openURL(String url) { String osName = System.getProperty("os.name"); try {// w ww . j a va2 s . c o m if (osName.startsWith("Mac OS")) { Class fileMgr = Class.forName("com.apple.eio.FileManager"); Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] { String.class }); openURL.invoke(null, new Object[] { url }); } else if (osName.startsWith("Windows")) Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url); else { //assume Unix or Linux String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" }; String browser = null; for (int count = 0; count < browsers.length && browser == null; count++) if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] }).waitFor() == 0) browser = browsers[count]; if (browser == null) throw new Exception("Could not find web browser"); else Runtime.getRuntime().exec(new String[] { browser, url }); } } catch (Exception e) { JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage()); } }
From source file:com.ori.outlierserver.model.DataUtil.java
public Classifier<Reading, OUTLIER_TYPE> getOutlierClassifierFromList(final List<Reading> list) throws Throwable { if (list == null) { throw new Exception("List cannot be null"); }// w w w. ja v a 2 s . co m if (list.size() < 1) { throw new Exception("List cannot be empty"); } final double[] fences = getOutlierBounderysFromLits(list); return new Classifier<Reading, OUTLIER_TYPE>() { @Override public OUTLIER_TYPE classify(final Reading object) throws Throwable { if (object == null) { throw new NullArgumentException("Object cannot be null"); } double median_value = object.getMedian_value(); if (median_value < fences[0] || median_value > fences[3]) { return OUTLIER_TYPE.MAJOR; } if (median_value >= fences[0] && median_value < fences[1] || median_value >= fences[2] && median_value < fences[3]) { return OUTLIER_TYPE.MINOR; } return OUTLIER_TYPE.NONE; } }; }
From source file:com.github.tomakehurst.wiremock.SavingMappingsAcceptanceTest.java
private static void resetFileSourceRoot() { try {// www. j a v a2s . c o m if (FILE_SOURCE_ROOT.exists()) { FileUtils.deleteDirectory(FILE_SOURCE_ROOT); } if (!FILES_DIRECTORY.mkdirs()) { throw new Exception("Could no create " + FILES_DIRECTORY.getAbsolutePath()); } if (!MAPPINGS_DIRECTORY.mkdirs()) { throw new Exception("Could no create " + MAPPINGS_DIRECTORY.getAbsolutePath()); } } catch (Exception e) { throw new RuntimeException(e); } }
From source file:SocketAddressEncoder.java
public static InetSocketAddress decode(String str) throws UnknownHostException { StringTokenizer st = new StringTokenizer(str, ","); if (st.countTokens() != 6) { throw new Exception("Illegal amount of tokens"); }/*from w ww. j av a 2s . co m*/ StringBuffer sb = new StringBuffer(); try { sb.append(convertAndValidateNumber(st.nextToken())); sb.append('.'); sb.append(convertAndValidateNumber(st.nextToken())); sb.append('.'); sb.append(convertAndValidateNumber(st.nextToken())); sb.append('.'); sb.append(convertAndValidateNumber(st.nextToken())); } catch (IllegalArgumentException e) { throw new Exception(e.getMessage()); } InetAddress dataAddr = InetAddress.getByName(sb.toString()); // get data server port int dataPort = 0; try { int hi = convertAndValidateNumber(st.nextToken()); int lo = convertAndValidateNumber(st.nextToken()); dataPort = (hi << 8) | lo; } catch (IllegalArgumentException ex) { throw new Exception("Invalid data port: " + str); } return new InetSocketAddress(dataAddr, dataPort); }
From source file:BrowserLauncher.java
public static void openURL(String url) { int os = PlatformDetector.detect(); try {//from ww w .j a v a 2s . c om if (os == PlatformDetector.MACOS) { Class macUtils = Class.forName("com.apple.mrj.MRJFileUtils"); Method openURL = macUtils.getDeclaredMethod("openURL", new Class[] { String.class }); openURL.invoke(null, new Object[] { url }); } else if (os == PlatformDetector.WINDOWS) Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url); else { // assume Unix or Linux String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" }; String browser = null; for (int count = 0; count < browsers.length && browser == null; count++) if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] }).waitFor() == 0) browser = browsers[count]; if (browser == null) throw new Exception("Could not find web browser."); else Runtime.getRuntime().exec(new String[] { browser, url }); } } catch (Exception e) { JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage()); } }
From source file:com.mycompany.supersimplestockmarket.StockMarket.java
public void recordTrade(Trade trade) throws Exception { if (trade.getStock() == null) throw new Exception("Cannot trade a null stock"); trades.add(trade);//from w w w . ja v a 2 s . co m lastTradePrices.put(trade.getStock(), trade.getTradePrice()); }