Example usage for java.lang IllegalArgumentException getMessage

List of usage examples for java.lang IllegalArgumentException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.carolinarollergirls.scoreboard.jetty.StreamServlet.java

protected void list(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {//w  ww . j ava 2s.co m
        File streamDir = new File(streamDirName);

        StringBuffer fileList = new StringBuffer("");
        File[] fileArray = streamDir.listFiles();
        if (null != fileArray) {
            Iterator<File> files = Arrays.asList(fileArray).iterator();
            while (files.hasNext()) {
                File f = files.next();
                if (f.isFile())
                    fileList.append(f.getName() + "\n");
            }
        }

        setTextResponse(response, HttpServletResponse.SC_OK, fileList.toString());
    } catch (FileNotFoundException fnfE) {
        setTextResponse(response, HttpServletResponse.SC_OK, "");
    } catch (IllegalArgumentException iaE) {
        setTextResponse(response, HttpServletResponse.SC_BAD_REQUEST, iaE.getMessage());
    }
}

From source file:com.thoughtworks.go.util.pool.DigestObjectPoolsTest.java

@Test
public void shouldThrowIllegalArgumentExceptionWhenTheAlgorithmIsUnknown() throws IOException {
    DigestObjectPools.DigestOperation operation = mock(DigestObjectPools.DigestOperation.class);
    try {/*w w  w  . ja  va  2 s.  co m*/
        pools.computeDigest("upside_down_fred_rubble_bubble_cake", operation);
        fail("Expected to get an exception as the algorithm is Flintstones proprietary!");
    } catch (IllegalArgumentException expected) {
        assertThat(expected.getMessage(), is("Algorithm not supported"));
    }
}

From source file:de.kaiserpfalzEdv.iam.core.identity.SubjectBuilder.java

@Override
public SubjectDO build() {
    SubjectDO result;/*from w w  w .jav a2s  .c o  m*/

    try {
        result = generate();
    } catch (IllegalArgumentException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }

    if (identity != null)
        result.setIdentity(identity);
    for (Role r : roles)
        result.addRole(r);

    result.validate();

    return result;
}

From source file:org.psikeds.common.services.AbstractRESTService.java

protected Response buildResponse(final IllegalArgumentException iaex) {
    return buildResponse(Status.BAD_REQUEST, iaex.getMessage());
}

From source file:edu.cudenver.bios.matrixsvc.resource.MatrixInversionResource.java

/**
 * Handle POST request to invert a matrix
 * @param entity XMl formatted matrix //from ww  w  .  j a v  a 2s .c o  m
 * @return XML representation of the matrix inverse
 * @throws ResourceException
 */
@Post
public Representation matrixInversion(Representation entity) throws ResourceException {
    if (entity == null) {
        throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "No Input- Matrix Inversion not possible");
    }
    DomRepresentation rep = new DomRepresentation(entity);
    NamedRealMatrix matrixInput = null;
    NamedRealMatrix inverseMatrix = null;
    try {
        // parse the parameters from the entity body
        matrixInput = MatrixParamParser
                .getMatrixInversionParamsFromDomNode(rep.getDocument().getDocumentElement());

        if (matrixInput == null || !matrixInput.getName().equalsIgnoreCase("A")) {
            throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,
                    "Couldn't retrieve the matrix for inversion.");
        }

        // perform inversion
        inverseMatrix = new NamedRealMatrix(new LUDecompositionImpl(matrixInput).getSolver().getInverse());

        // set name
        inverseMatrix.setName(MatrixConstants.INVERSION_MATRIX_RETURN_NAME);

        //create our response representation
        MatrixXmlRepresentation response = new MatrixXmlRepresentation(inverseMatrix);
        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:org.elasticsearch.client.RestClientTests.java

public void testPerformAsyncWithWrongEndpoint() throws Exception {
    RestClient.SyncResponseListener listener = new RestClient.SyncResponseListener(10000);
    try (RestClient restClient = createRestClient()) {
        restClient.performRequestAsync("GET", "::http:///", listener);
        listener.get();/*  www.ja  v a 2  s  .c o m*/

        fail("should have failed because of wrong endpoint");
    } catch (IllegalArgumentException exception) {
        assertEquals("Expected scheme name at index 0: ::http:///", exception.getMessage());
    }
}

From source file:de.kaiserpfalzEdv.iam.core.role.RoleBuilder.java

@Override
public RoleDO build() {
    RoleDO result;//  w  w  w.ja v  a2  s .c o m

    try {
        result = generate();
    } catch (IllegalArgumentException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }

    for (Permission p : extendingPermissions)
        result.extendPermission(p);
    for (Permission p : restrictingPermissions)
        result.restrictPermission(p);
    for (Role r : children)
        result.addRole(r);

    result.validate();

    return result;
}

From source file:de.zalando.awsqueen.awqfetch.FetchCLI.java

@Override
public void run(final String... args) {

    try {/*w  w  w. j av  a 2  s . c o m*/
        checkArgument(args.length == 1, "Number of arguments must be exactly 1");
    } catch (final IllegalArgumentException e) {
        System.out.println(e.getMessage() + " Usage:\n" //
                + "run.sh <service>");
    }

    final String service = args[0];
    Path currentDirPath = Paths.get(currentDir);
    Region region = null;

    try {
        region = Region.getRegion(Regions.fromName(currentDirPath.toFile().getName()));
    } catch (final IllegalArgumentException e) {
        System.out.println("Region " + currentDir + " not found in AWS");
    }

    if (region == null) {
        System.exit(1);
    }

    try {
        switch (service) {

        case "ec2":
            fetchEC2(region);
            break;

        case "elb":
            System.out.println("elb");
            break;

        default:

            break;
        }
    } catch (final IllegalArgumentException e) {
        System.out.println(e.getMessage() + " Usage:\n" //
                + "run.sh <service>");
    }
}

From source file:de.kaiserpfalzEdv.iam.core.identity.IdentityBuilder.java

@Override
public IdentityDO build() {
    IdentityDO result;// w  ww  . j  a v a  2 s.  co  m

    try {
        result = generate();
    } catch (IllegalArgumentException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }

    result.setSubjects(subjects);

    result.validate();

    return result;
}

From source file:edu.depaul.armada.dao.PreferenceDaoTest.java

@Test
public void testStorePreference() {

    try {//from   w  ww. j  av  a  2 s  .co m
        dao.storePreference(null);
        fail("Expected IllegalArgumentException!");
    } catch (IllegalArgumentException iae) {
        assertEquals("preference instance cannot be null!", iae.getMessage());
    }

    Preference preference = newPreference("cpu");
    dao.storePreference(preference);

    List<DashboardPreference> preferences = dao.getAll();

    assertEquals(1, preferences.size());
}