private IllegalArgumentException incorrectInputName(IOException e, String name) { IllegalArgumentException iae = new IllegalArgumentException("Incorrect input name:" + name); iae.initCause(e); throw iae; }
private IllegalArgumentException incorrectInputEncoding(IOException e) { IllegalArgumentException iae = new IllegalArgumentException("Incorrect input encoding"); iae.initCause(e); throw iae; }
/** * Throws a {@link org.apache.geode.cache.CacheXmlException} */ @Override public void fatalError(SAXParseException ex) throws SAXException { IllegalArgumentException ex2 = new IllegalArgumentException( "Fatal error while parsing XML."); ex2.initCause(ex); throw ex2; }
/** * Throws a {@link org.apache.geode.cache.CacheXmlException} */ @Override public void error(SAXParseException ex) throws SAXException { IllegalArgumentException ex2 = new IllegalArgumentException( "Error while parsing XML."); ex2.initCause(ex); throw ex2; }
/** * Parse numeric component into an int. * * @param value Numeric component * @param version Complete version string for exception message, if any * @return int value of numeric component */ private static int parseInt(String value, String version) { try { return Integer.parseInt(value); } catch (NumberFormatException e) { IllegalArgumentException iae = new IllegalArgumentException("invalid version \"" + version + "\": non-numeric \"" + value + "\""); iae.initCause(e); throw iae; } }
private static URI createURI(String brokerURL) { try { return new URI(brokerURL); } catch (URISyntaxException e) { throw (IllegalArgumentException)new IllegalArgumentException("Invalid broker URI: " + brokerURL).initCause(e); } }
/** * Verify and obtain a required String property. * * @param propName The name of the property * @return The value of the property or {@code null} if the property is not * set. * @throws IllegalArgumentException when the property doesn't have the * correct data type. */ private String verifyStringProperty(String propName) { Object r = properties.get(propName); try { return (String) r; } catch (ClassCastException e) { IllegalArgumentException iae = new IllegalArgumentException("property value is not a String: " + propName); iae.initCause(e); throw iae; } }
public void foo(File f) { try { FileOutputStream o = new FileOutputStream(f); o.write(0); o.close(); } catch (IOException e) { IllegalArgumentException e2 = new IllegalArgumentException("Bad file: " + f); e2.initCause(e); } }
/** * Parses the supplied LDAP URL. * @param url the URL (e.g. * <tt>ldap://monkeymachine:11389/dc=springframework,dc=org</tt>). * @return the URI object created from the URL * @throws IllegalArgumentException if the URL is null, empty or the URI syntax is * invalid. */ private static URI parseLdapUrl(String url) { Assert.hasLength(url, "url must have length"); try { return new URI(url); } catch (URISyntaxException e) { IllegalArgumentException iae = new IllegalArgumentException( "Unable to parse url: " + url); iae.initCause(e); throw iae; } } }
/** * Verify and obtain a required long property. * * @param propName The name of the property * @return The value of the property or 0 if the property is not set. * @throws IllegalArgumentException when the property doesn't have the * correct data type. */ private long verifyLongProperty(String propName) { Object r = properties.get(propName); if (r == null) { return 0l; } try { return ((Long) r).longValue(); } catch (ClassCastException e) { IllegalArgumentException iae = new IllegalArgumentException("property value is not a Long: " + propName); iae.initCause(e); throw iae; } }
/** * Parse version component into a Version. * * @param version version component string * @param range Complete range string for exception message, if any * @return Version */ private static Version parseVersion(String version, String range) { try { return Version.valueOf(version); } catch (IllegalArgumentException e) { IllegalArgumentException iae = new IllegalArgumentException("invalid range \"" + range + "\": " + e.getMessage()); iae.initCause(e); throw iae; } }
/** * Parse filter string into a Filter object. * * @param filterString The filter string to parse. * @return a Filter for this bundle. * @throws IllegalArgumentException If the filter syntax is invalid. */ private static Filter parseFilter(String filterString) { filterString = filterString.trim(); if (filterString.equals("*")) { return null; } try { return FrameworkUtil.createFilter(filterString); } catch (InvalidSyntaxException e) { IllegalArgumentException iae = new IllegalArgumentException("invalid filter"); iae.initCause(e); throw iae; } }
/** * It's a lot easier to configure and manage the location of the graphite server if we combine * the ip and port into a single string. Using a "fake" transport and the ipString means we get * standard host/port parsing (including domain names, ipv4 and ipv6) for free. */ private static URI parseStringAsUri(String ipString) { try { URI uri = new URI("socket://" + ipString); if (uri.getHost() == null || uri.getPort() == -1) { throw new URISyntaxException(ipString, "URI must have host and port parts"); } return uri; } catch (URISyntaxException e) { throw (IllegalArgumentException) new IllegalArgumentException( "Graphite server address needs to be defined as {host}:{port}.").initCause(e); } } }
/** * Parse filter string into a Filter object. * * @param filterString The filter string to parse. * @return a Filter for this bundle. If the specified filterString is not a * filter expression, then {@code null} is returned. * @throws IllegalArgumentException If the filter syntax is invalid. */ private static Filter parseFilter(String filterString) { filterString = filterString.trim(); if (filterString.charAt(0) != '(') { return null; } try { return FrameworkUtil.createFilter(filterString); } catch (InvalidSyntaxException e) { IllegalArgumentException iae = new IllegalArgumentException("invalid filter"); iae.initCause(e); throw iae; } }
/** * Parse filter string into a Filter object. * * @param filterString The filter string to parse. * @return a Filter for this bundle. If the specified filterString is not a * filter expression, then {@code null} is returned. * @throws IllegalArgumentException If the filter syntax is invalid. */ private static Filter parseFilter(String filterString) { filterString = filterString.trim(); if (filterString.charAt(0) != '(') { return null; } try { return FrameworkUtil.createFilter(filterString); } catch (InvalidSyntaxException e) { IllegalArgumentException iae = new IllegalArgumentException("invalid filter"); iae.initCause(e); throw iae; } }
/** * Parse filter string into a Filter object. * * @param filterString The filter string to parse. * @return a Filter for this bundle. If the specified filterString is not a * filter expression, then {@code null} is returned. * @throws IllegalArgumentException If the filter syntax is invalid. */ private static Filter parseFilter(String filterString) { filterString = filterString.trim(); if (filterString.charAt(0) != '(') { return null; } try { return FrameworkUtil.createFilter(filterString); } catch (InvalidSyntaxException e) { IllegalArgumentException iae = new IllegalArgumentException("invalid filter"); iae.initCause(e); throw iae; } }
/** * Parse filter string into a Filter object. * * @param filterString The filter string to parse. * @return a Filter for this bundle. If the specified filterString is * {@code null} or equals "*", then {@code null} is returned to * indicate a wildcard. * @throws IllegalArgumentException If the filter syntax is invalid. */ private static Filter parseFilter(String filterString) { if (filterString == null) { return null; } filterString = filterString.trim(); if (filterString.equals("*")) { return null; } try { return FrameworkUtil.createFilter(filterString); } catch (InvalidSyntaxException e) { IllegalArgumentException iae = new IllegalArgumentException("invalid filter"); iae.initCause(e); throw iae; } }
/** * Parse filter string into a Filter object. * * @param filterString The filter string to parse. * @return a Filter for this bundle. * @throws IllegalArgumentException If the filter syntax is invalid. */ private static Filter parseFilter(String filterString) { filterString = filterString.trim(); if (filterString.equals("*")) { return null; } try { return FrameworkUtil.createFilter(filterString); } catch (InvalidSyntaxException e) { IllegalArgumentException iae = new IllegalArgumentException("invalid filter"); iae.initCause(e); throw iae; } }
/** * Parse filter string into a Filter object. * * @param filterString The filter string to parse. * @return a Filter for this subsystem. If the specified filterString equals * "*", then {@code null} is returned to indicate a wildcard. * @throws IllegalArgumentException If the filter syntax is invalid. */ private static Filter parseFilter(String filterString) { filterString = filterString.trim(); if (filterString.equals("*")) { return null; } try { return FrameworkUtil.createFilter(filterString); } catch (InvalidSyntaxException e) { IllegalArgumentException iae = new IllegalArgumentException("invalid filter"); iae.initCause(e); throw iae; } }
@Override public void unaryCall(SimpleRequest request, StreamObserver<SimpleResponse> responseObserver) { IllegalStateException e1 = new IllegalStateException("Exception 1"); IllegalArgumentException e2 = new IllegalArgumentException(); AssertionError e3 = new AssertionError("Exception 3"); Exceptions.clearTrace(e3); RuntimeException e4 = new RuntimeException("Exception 4"); e1.initCause(e2); e2.initCause(e3); e3.initCause(e4); Status status = Status.ABORTED.withCause(e1); responseObserver.onError(status.asRuntimeException()); } }