List of usage examples for java.lang IllegalArgumentException getMessage
public String getMessage()
From source file:com.twitter.distributedlog.service.DistributedLogServerApp.java
private void run() { try {/* w w w . jav a2 s .c o m*/ logger.info("Running distributedlog server : args = {}", Arrays.toString(args)); BasicParser parser = new BasicParser(); CommandLine cmdline = parser.parse(options, args); runCmd(cmdline); } catch (ParseException pe) { logger.error("Argument error : {}", pe.getMessage()); printUsage(); Runtime.getRuntime().exit(-1); } catch (IllegalArgumentException iae) { logger.error("Argument error : {}", iae.getMessage()); printUsage(); Runtime.getRuntime().exit(-1); } catch (ConfigurationException ce) { logger.error("Configuration error : {}", ce.getMessage()); printUsage(); Runtime.getRuntime().exit(-1); } catch (IOException ie) { logger.error("Failed to start distributedlog server : ", ie); Runtime.getRuntime().exit(-1); } }
From source file:org.inbio.ait.web.ajax.controller.ExportCsvController.java
@Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String paramLayer = request.getParameter("layers"); String paramTaxon = request.getParameter("taxons"); String paramIndi = request.getParameter("indi"); String errorMsj = "Error con los parmetros: " + paramLayer + " " + paramTaxon + " " + paramIndi; try {/* w w w .j a va 2s.c om*/ //Arrays that contains the parameters data String[] layerArray = paramLayer.split("\\|"); String[] taxonArray = paramTaxon.split("\\|"); String[] indiArray = paramIndi.split("\\|"); //Specimens that match with the search criteria List<Specimen> specimens = pointsManager.specimensByCriteria(layerArray, taxonArray, indiArray); return writeReponse(request, response, specimens); } catch (IllegalArgumentException iae) { throw new Exception(errorMsj + " " + iae.getMessage()); } }
From source file:com.sshtools.j2ssh.authentication.UserGridCredential.java
private static GSSCredential saslProxy(SshConnectionProperties properties, String password, int lengthHours) throws IOException { String hostname_k = DEFAULT_MYPROXY_SERVER_K; hostname_k = PreferencesStore.get(SshTerminalPanel.PREF_KRB5_MYPROXY_HOSTNAME, hostname_k); String username = System.getProperty("user.name"); String realm = System.getenv("USERDNSDOMAIN"); String kdc = System.getenv("USERDNSDOMAIN"); String port_S = DEFAULT_MYPROXY_PORT_K; boolean use = true; if (properties != null) { if (!(properties instanceof SshToolsConnectionProfile)) return null; SshToolsConnectionProfile profile = (SshToolsConnectionProfile) properties; hostname_k = profile.getApplicationProperty(SshTerminalPanel.PREF_KRB5_MYPROXY_HOSTNAME, hostname_k); username = profile.getApplicationProperty(SshTerminalPanel.PREF_KRB5_MYPROXY_USERNAME, username); realm = profile.getApplicationProperty(SshTerminalPanel.PREF_KRB5_MYPROXY_REALM, realm); kdc = profile.getApplicationProperty(SshTerminalPanel.PREF_KRB5_MYPROXY_KDC, kdc); use = profile.getApplicationPropertyBoolean(SshTerminalPanel.PREF_KRB5_MYPROXY_USE, use); }/*from w ww .j a va 2 s . c om*/ use = use && SshTerminalPanel.PREF_KRB5_MYPROXY_ENABLED; // was support compiled in? if (!use) return null; port_S = PreferencesStore.get(SshTerminalPanel.PREF_KRB5_MYPROXY_PORT, port_S); int port = 7513; try { port = Integer.parseInt(port_S); } catch (NumberFormatException e) { log.warn("Could not parse the port number from defaults file (property name" + SshTerminalPanel.PREF_KRB5_MYPROXY_PORT + ", property value= " + port_S + ")."); } GSSCredential gsscredential = null; CoGProperties cogproperties = CoGProperties.getDefault(); CertUtil.init(); MyProxy myproxy = new MyProxy(hostname_k, port); try { SASLParams params = null; if (password != null) { params = new SASLParams(username, password); } else { params = new SASLParams(username); } params.setRealm(realm); params.setLifetime(lengthHours * 3600); params.setKDC(kdc); gsscredential = myproxy.getSASL(null, params); if (SAVE_MYPROXY_PROXY) { GlobusCredential proxy = ((GlobusGSSCredentialImpl) gsscredential).getGlobusCredential(); ProxyHelper.saveProxy(proxy, properties); } log.debug("A proxy has been received for user " + username); } catch (IllegalArgumentException exception) { exception.printStackTrace(); StringWriter stringwriter = new StringWriter(); exception.printStackTrace(new PrintWriter(stringwriter)); log.debug(stringwriter); myProxyPrompt.setError("MyProxy: " + exception.getMessage()); ; } catch (Exception exception) { exception.printStackTrace(); StringWriter stringwriter = new StringWriter(); exception.printStackTrace(new PrintWriter(stringwriter)); log.debug(stringwriter); } return gsscredential; }
From source file:com.puppycrawl.tools.checkstyle.checks.sizes.FileLengthCheckTest.java
@Test public void testExtensions() throws Exception { FileLengthCheck check = new FileLengthCheck(); check.setFileExtensions("java"); assertEquals("extension should be the same", ".java", check.getFileExtensions()[0]); check.setFileExtensions(".java"); assertEquals("extension should be the same", ".java", check.getFileExtensions()[0]); try {/*from ww w. j a v a 2 s .c o m*/ check.setFileExtensions((String[]) null); fail(); } catch (IllegalArgumentException ex) { assertEquals("Extensions array can not be null", ex.getMessage()); } }
From source file:com.betfair.tornjak.monitor.aop.AopTest.java
@Test @DirtiesContext//from w w w. j a v a2 s . c o m public void testBadMonitorName() throws Exception { try { aopBean.methodFour(); fail("Exception should be thrown"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("flubber")); } }
From source file:edu.cudenver.bios.matrixsvc.resource.MatrixDecompositionCholeskyResource.java
/** * This operation takes a single square matrix (p x p) * and produces two matrices: the matrix representing its * square root (L), and its transpose. Please see * Matrix Services REST API documentation for details on * the entity body format./* w w w .j av a2 s.c om*/ * * @param entity HTTP entity body for the request * @throws NotPositiveDefiniteMatrixException * @throws NotSymmetricMatrixException * @throws NonSquareMatrixException */ @Post public Representation acceptRepresentation(Representation entity) throws ResourceException, NonSquareMatrixException, NotSymmetricMatrixException, NotPositiveDefiniteMatrixException { if (entity == null) { throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No Input- Matrix Decomposition not possible"); } DomRepresentation rep = new DomRepresentation(entity); NamedRealMatrix matrixInput = null; try { // parse the parameters from the entity body matrixInput = MatrixParamParser .getDecompCholeskyParamsFromDomNode(rep.getDocument().getDocumentElement()); if (matrixInput == null || !matrixInput.getName().equalsIgnoreCase("A")) { throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Couldn't retrieve the matrix for Cholesky Decomposition."); } // perform Cholesky Decomposition CholeskyDecompositionImpl cdImpl = new CholeskyDecompositionImpl(matrixInput); //create our response representation CholeskyDecompositionXmlRepresentation response = new CholeskyDecompositionXmlRepresentation(cdImpl); /* getResponse().setEntity(response); getResponse().setStatus(Status.SUCCESS_CREATED);*/ return response; } catch (IllegalArgumentException iae) { MatrixLogger.getInstance().error(iae.getMessage()); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, iae.getMessage()); } catch (IOException ioe) { MatrixLogger.getInstance().error(ioe.getMessage()); throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, ioe.getMessage()); } }
From source file:de.steilerdev.myVerein.server.security.RememberMeTokenDataProvider.java
@Override public void removeUserTokens(String username) { List<RememberMeToken> tokens = rememberMeTokenRepository.findRememberMeTokenByUsername(username); if (tokens != null) { logger.debug("Deleting remember me token for user " + username); try {/*from w ww . j ava 2 s . c o m*/ rememberMeTokenRepository.delete(tokens); } catch (IllegalArgumentException e) { logger.error("Unable to delete remember me token for user " + username + ": " + e.getMessage()); } } else { logger.warn("Unable to delete remember me token for user " + username); } }
From source file:com.mapr.synth.samplers.VinSamplerTest.java
@Test public void testCheckDigit() throws FileNotFoundException { // test cases from http://introcs.cs.princeton.edu/java/31datatype/VIN.java.html // % java VIN 1B4YEM9P4KP186543 // Invalid ///*from w w w .j ava 2s .c o m*/ // % java VIN 1FA-CP45E-X-LF192944 // Valid // // % java VIN 1FA-CP45E-6-LF192944 // Invalid // // % java VIN QFA-CP45E-X-LF192944 // Exception in thread "main" java.lang.RuntimeException: Illegal character: Q // // % java VIN 1FA-CP45E-G-LF192944 // Exception in thread "main" java.lang.RuntimeException: Illegal check digit: G // // % java VIN 1FA-CP45E-X-LF19294 // Exception in thread "main" java.lang.RuntimeException: VIN number must be 17 characters VinSampler vs = new VinSampler(); String[] vins = { "1B4YEM9P4KP186543", "1FACP45EXLF192944", "1FACP45E6LF192944", "1FACP45EGLF192944", "11111111111111111" }; boolean[] check = { false, true, false, false, true, true }; for (int i = 0; i < vins.length; i++) { assertEquals(check[i], vins[i].equals(vs.addCheckDigit(vins[i]))); } try { vs.addCheckDigit("QFACP45EXLF192944"); fail("Should have failed with IllegalArgumentException"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().startsWith("Invalid character")); } }
From source file:com.netflix.spinnaker.halyard.config.error.v1.ParseConfigException.java
public ParseConfigException(IllegalArgumentException e) { Problem problem = new ConfigProblemBuilder(Problem.Severity.FATAL, "Could not translate your halconfig: " + e.getMessage()).build(); getProblems().add(problem);/* w w w . j a v a 2 s. c o m*/ }
From source file:eu.danieldk.nlp.conllx.reader.CONLLReader.java
/** * Construct a sentence. If strictness is used and invariants do not hold, convert * the exception to an IOException.//from w ww . java 2 s . co m */ private Sentence constructSentence(List<Token> tokens) throws IOException { Sentence sentence; try { sentence = new SimpleSentence(tokens, strict); } catch (IllegalArgumentException e) { throw new IOException(e.getMessage()); } return sentence; }