List of usage examples for java.lang IllegalArgumentException getMessage
public String getMessage()
From source file:com.eharmony.services.swagger.resource.DashboardRepositoryResource.java
/** * Saves a services dashboard. Validates all required fields. If the same service name and * environment is found, it is overwritten. * * @param dashboard The unique dashboard id. *///from w w w . ja v a2 s. c o m @PUT @Path(value = "/{id}") @ApiOperation(value = "Save dashboard", notes = "Saves a services dashboard. Validates all required fields. If the same service name and " + "environment is found, it is overwritten.") @ApiResponses({ @ApiResponse(code = 200, message = "The dashboard was overwritten successfully."), @ApiResponse(code = 201, message = "The dashboard was created successfully."), @ApiResponse(code = 400, message = "A required field is missing."), @ApiResponse(code = 500, message = "An error occurred when attempting to save the dashboard.") }) public Response saveDashboard( @PathParam(value = "id") @ApiParam(value = "The unique dashboard id.") String dashboardId, @ApiParam(value = "A dashboard object") Dashboard dashboard) { try { validateDashboard(dashboard); repository.saveDashboard(dashboard); return Response.ok(dashboard).build(); } catch (IllegalArgumentException iae) { return Response.status(400).entity(iae.getMessage()).build(); } catch (Exception ex) { LOG.error("Unable to save dashboard", ex); return Response.serverError().build(); } }
From source file:com.liyablieva.jaxws.endpoint.EmployeeServiceEndpoint.java
@WebMethod public void getEmployees(@XmlElement(required = true) @WebParam(name = "department") String department, @WebParam(name = "result", mode = WebParam.Mode.OUT) Holder<Integer> result, @WebParam(name = "description", mode = WebParam.Mode.OUT) Holder<String> description, @WebParam(name = "employees_list", mode = WebParam.Mode.OUT) Holder<List<Employee>> employees) { try {/*from w ww . j a v a2 s . co m*/ GetEmployeesResponseType response = employeeService.getEmployees(department); result.value = response.getResult(); employees.value = response.getEmployees(); description.value = response.getDescription(); } catch (IllegalArgumentException ex) { System.out.println("IllegalArgumentException in getEmployee: " + ex); result.value = -1; description.value = ex.getMessage(); } catch (Exception ex) { System.out.println("Exception in getEmployee: " + ex); result.value = -2; description.value = ex.getMessage(); } }
From source file:io.mesosphere.mesos.frameworks.cassandra.scheduler.api.ScaleOutController.java
/** * Allows to scale out the Cassandra cluster by increasing the number of nodes. * Requires the query parameter {@code nodes} defining the desired number of total nodes. * Must be submitted using HTTP method {@code POST}. *//* w w w . j av a 2 s .c o m*/ @POST @Path("/nodes") public Response updateNodeCount(@QueryParam("nodeCount") final int nodeCount) { try { final int newCount = cluster.updateNodeCount(nodeCount); return JaxRsUtils.buildStreamingResponse(factory, new StreamingJsonResponse() { @Override public void write(final JsonGenerator json) throws IOException { json.writeNumberField("newNodeCount", newCount); } }); } catch (IllegalArgumentException e) { return Response.status(Response.Status.BAD_REQUEST).type("application/json") .entity(String.format("{\"message\":\"%s\"}", e.getMessage())).build(); } }
From source file:org.cloudfoundry.identity.uaa.web.ForwardAwareInternalResourceViewResolver.java
private MediaType getMediaTypes(HttpServletRequest request) { String acceptHeader = request.getHeader(ACCEPT_HEADER); if (StringUtils.hasText(acceptHeader)) { try {/* w w w. j a v a 2 s . c om*/ List<MediaType> acceptableMediaTypes = MediaType.parseMediaTypes(acceptHeader); return acceptableMediaTypes.isEmpty() ? null : acceptableMediaTypes.get(0); } catch (IllegalArgumentException ex) { if (logger.isDebugEnabled()) { logger.debug("Could not parse accept header [" + acceptHeader + "]: " + ex.getMessage()); } return null; } } return null; }
From source file:com.microsoft.rest.ValidatorTests.java
@Test public void validateInteger() throws Exception { IntegerWrapper body = new IntegerWrapper(); body.value = 3;/*from www. ja va 2s . c o m*/ Validator.validate(body); // pass try { body.value = null; Validator.validate(body); // fail fail(); } catch (IllegalArgumentException ex) { Assert.assertTrue(ex.getMessage().contains("value is required")); } }
From source file:com.microsoft.rest.ValidatorTests.java
@Test public void validateString() throws Exception { StringWrapper body = new StringWrapper(); body.value = ""; Validator.validate(body); // pass try {/*from w w w . j av a 2s . c o m*/ body.value = null; Validator.validate(body); // fail fail(); } catch (IllegalArgumentException ex) { Assert.assertTrue(ex.getMessage().contains("value is required")); } }
From source file:com.microsoft.rest.ValidatorTests.java
@Test public void validateLocalDate() throws Exception { LocalDateWrapper body = new LocalDateWrapper(); body.value = new LocalDate(1, 2, 3); Validator.validate(body); // pass try {/*from ww w.j av a 2s . c om*/ body.value = null; Validator.validate(body); // fail fail(); } catch (IllegalArgumentException ex) { Assert.assertTrue(ex.getMessage().contains("value is required")); } }
From source file:edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectionSetup.java
private void setUpSelections() { List<Locale> locales = new ArrayList<Locale>(); for (String string : splitSelectables()) { try {/* w w w. j av a 2 s . c o m*/ locales.add(buildLocale(string)); } catch (IllegalArgumentException e) { ssWarning("Problem in '" + PROPERTY_SELECTABLE_LOCALES + "': " + e.getMessage()); } } SelectedLocale.setSelectableLocales(ctx, locales); ssInfo("Setting selectable locales to '" + locales + "'."); }
From source file:com.itemanalysis.jmetrik.graph.nicc.NonparametricCurvePanel.java
private void processCommand() { try {//from w w w . j a v a 2 s .c om names = command.getFreeOptionList("variables").getString(); xlabel = command.getFreeOption("xvar").getString(); ylabel = "Probability"; if (command.getSelectOneOption("curves").isValueSelected("expected")) ylabel = "Expected Value"; this.setLayout(new GridLayout(names.size() + 1, 1)); } catch (IllegalArgumentException ex) { logger.fatal(ex.getMessage(), ex); this.firePropertyChange("error", "", "Error - Check log for details."); } }
From source file:com.smartitengineering.cms.content.api.impl.IdTest.java
public void testSettersWithColon() { final String suffix = ContentTypeIdImpl.STANDARD_ERROR_MSG.substring(2); WorkspaceIdImpl workspaceIdImpl = new WorkspaceIdImpl(); try {/* w w w .ja va 2 s. c o m*/ workspaceIdImpl.setGlobalNamespace("global:"); fail("Setter with colon should not exit normally"); } catch (IllegalArgumentException exception) { assertTrue(exception.getMessage().endsWith(suffix)); } try { workspaceIdImpl.setName("work:space"); fail("Setter with colon should not exit normally"); } catch (IllegalArgumentException exception) { assertTrue(exception.getMessage().endsWith(suffix)); } ContentTypeIdImpl idImpl = new ContentTypeIdImpl(); idImpl.setWorkspace(workspaceIdImpl); try { idImpl.setNamespace("contentType:NS"); fail("Setter with colon should not exit normally"); } catch (IllegalArgumentException exception) { assertTrue(exception.getMessage().endsWith(suffix)); } try { idImpl.setName(":contentTypeName"); fail("Setter with colon should not exit normally"); } catch (IllegalArgumentException exception) { assertTrue(exception.getMessage().endsWith(suffix)); } }