Example usage for java.lang Exception getClass

List of usage examples for java.lang Exception getClass

Introduction

In this page you can find the example usage for java.lang Exception getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:me.Laubi.MineMaze.SubCommands.java

@SubCommand(alias = "maze", permission = "worldedit.minemaze.generate", author = "Laubi", description = "Create you own maze")
public static void maze(LocalPlayer player, CommandHandler handler, MineMazePlugin plugin) {
    final WorldEdit we = plugin.getWorldEdit();
    try {/*from w w w . j  a  v  a  2 s . co m*/
        Method mazeGen;
        LocalSession session;
        Region r;

        r = (session = we.getSession(player)).getSelection(player.getWorld());

        if (handler.containsArgument("gen")) {
            mazeGen = plugin.getMazeGeneratorByAlias(handler.getArgumentValue("gen"));
        } else {
            mazeGen = plugin.getMazeGenerators()
                    .get(MineMazePlugin.rnd.nextInt(plugin.getMazeGenerators().size()));
        }

        if (mazeGen == null)
            throw new MineMazeException("Could not find the choosen mazegenerator");

        if (!validateRegion(r, mazeGen)) {
            throw new MineMazeException("Your selection doesn't fit the requirements!");
        }

        try {
            Maze maze = (Maze) mazeGen.invoke(null, player, handler, we, new Maze(r));

            EditSession edit = session.createEditSession(player);
            edit.enableQueue();
            session.tellVersion(player);
            int affected = 0;

            for (int x = 0; x < maze.getWidth(); x++) {
                for (int y = 0; y < maze.getHeight(); y++) {
                    for (int z = 0; z < maze.getLength(); z++) {
                        Vector v = new Vector(x, y, z);
                        if (edit.setBlock(r.getMinimumPoint().add(v), maze.get(v))) {
                            affected++;
                        }
                    }
                }
            }
            session.remember(edit);
            edit.flushQueue();
            we.flushBlockBag(player, edit);
            player.print(affected + " block(s) have been changed.");
        } catch (Exception e) {
            throw e.getCause();
        }
    } catch (IncompleteRegionException e) {
        player.printError("Make a region selection first.");
    } catch (NumberFormatException e) {
        player.printError("Number expected; string given.");
    } catch (MaxChangedBlocksException e) {
        player.printError("Max blocks changed in an operation reached (" + e.getBlockLimit() + ").");
    } catch (UnknownItemException e) {
        player.printError("Block name '" + e.getID() + "' was not recognized.");
    } catch (InvalidItemException e) {
        player.printError(e.getMessage());
    } catch (DisallowedItemException e) {
        player.printError("Block '" + e.getID() + "' not allowed (see WorldEdit configuration).");
    } catch (MineMazeException e) {
        player.printError(e.getMessage());
    } catch (Throwable e) {
        player.printError("Please report this error: [See console]");
        player.printRaw(e.getClass().getName() + ": " + e.getMessage());
        e.printStackTrace();
    }
}

From source file:gov.nih.nci.cacis.common.schematron.SchematronValidatingErrorInterceptor.java

private Object getFaultInfo(Exception e) throws SecurityException, NoSuchMethodException,
        IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    return e.getClass().getMethod("getFaultInfo").invoke(e);
}

From source file:dtu.ds.warnme.ws.rest.json.AbstractRestWS.java

protected String getMessage(Exception ex, Locale locale) {
    ExceptionResponseMessage message = new ExceptionResponseMessage();
    message.setExceptionClassName(ex.getClass().getSimpleName());
    message.setExceptionMessage(ex.getMessage());
    if (ex instanceof AbstractCodeException
            && !StringUtils.isBlank(((AbstractCodeException) ex).getExceptionCode())) {
        message.setCustomCode(((AbstractCodeException) ex).getExceptionCode());
        message.setCustomMessage(//from   w  w  w  .j av a  2 s  . co  m
                ResourceBundleUtils.getValue(((AbstractCodeException) ex).getExceptionCode(), locale));
        message.setCustomMessageLocale(locale);
    }
    return GsonHolder.getGson().toJson(message);
}

From source file:com.adaptris.security.SingleEntryKeystoreBase.java

public void testImportCertificate() throws Exception {
    KeystoreProxy ksp = KeystoreFactory.getDefault().create(kloc);
    ksp.load();/* w  ww.  ja  va  2s .  co  m*/
    try {
        ksp.setCertificate("", "");
        fail("Import successful");
    } catch (Exception e) {
        assertEquals(KeystoreException.class, e.getClass());
        assertTrue(e.getMessage().matches(".*is implicitly read-only.*"));
    }
    try {
        ksp.setCertificate("", (Certificate) null);
        fail("Import successful");
    } catch (Exception e) {
        assertEquals(KeystoreException.class, e.getClass());
        assertTrue(e.getMessage().matches(".*is implicitly read-only.*"));
    }
    try {
        ksp.setCertificate("", (InputStream) null);
        fail("Import successful");
    } catch (Exception e) {
        assertEquals(KeystoreException.class, e.getClass());
        assertTrue(e.getMessage().matches(".*is implicitly read-only.*"));
    }
    try {
        ksp.setCertificate("", (File) null);
        fail("Import successful");
    } catch (Exception e) {
        assertEquals(KeystoreException.class, e.getClass());
        assertTrue(e.getMessage().matches(".*is implicitly read-only.*"));
    }
}

From source file:com.bt.aloha.fitnesse.InboundConferenceFixture.java

public String inviteParticipant() {
    try {/*from  w w w . jav a  2  s. co m*/
        conferenceBean.inviteParticipant(conferenceId, getDialogId());
        return "OK";
    } catch (Exception e) {
        return "Exception:" + e.getClass().getSimpleName();
    }
}

From source file:gov.va.isaac.search.CompositeSearchResultComparator.java

/**
 * Note, the primary getBestScore() sort is in reverse, so it goes highest to lowest
 *
 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
 *//*from w w  w.  j  av  a 2 s . co m*/
@Override
public int compare(CompositeSearchResult o1, CompositeSearchResult o2) {
    if (o1.getBestScore() < o2.getBestScore()) {
        return 1;
    } else if (o1.getBestScore() > o2.getBestScore()) {
        return -1;
    }

    if (o1.getContainingConcept() == null || o2.getContainingConcept() == null) {
        if (o1.getContainingConcept() == null && o2.getContainingConcept() != null) {
            return 1;
        } else if (o1.getContainingConcept() != null && o2.getContainingConcept() == null) {
            return -1;
        } else {
            return 0;
        }
    }
    // else same score
    String o1FSN = null;
    try {
        o1FSN = o1.getContainingConcept().getFullySpecifiedDescription().getText().trim();
    } catch (Exception e) {
        LOG.warn("Failed calling getFullySpecifiedDescription() (" + e.getClass().getName() + " \""
                + e.getLocalizedMessage() + "\") on concept " + o1, e);
    }
    String o2FSN = null;
    try {
        o2FSN = o2.getContainingConcept().getFullySpecifiedDescription().getText().trim();
    } catch (Exception e) {
        LOG.warn("Failed calling getFullySpecifiedDescription() (" + e.getClass().getName() + " \""
                + e.getLocalizedMessage() + "\") on concept " + o2, e);
    }

    int fsnComparison = ObjectUtils.compare(o1FSN, o2FSN);
    if (fsnComparison != 0) {
        return fsnComparison;
    }

    // else same score and FSN
    String o1PreferredDescription = null;
    try {
        o1PreferredDescription = o1.getContainingConcept().getPreferredDescription().getText().trim();
    } catch (Exception e) {
        LOG.debug("Failed calling getPreferredDescription() (" + e.getClass().getName() + " \""
                + e.getLocalizedMessage() + "\") on concept " + o1, e);
    }

    String o2PreferredDescription = null;
    try {
        o2PreferredDescription = o2.getContainingConcept().getPreferredDescription().getText().trim();
    } catch (Exception e) {
        LOG.debug("Failed calling getPreferredDescription() (" + e.getClass().getName() + " \""
                + e.getLocalizedMessage() + "\") on concept " + o2, e);
    }

    int prefDescComparison = ObjectUtils.compare(o1PreferredDescription, o2PreferredDescription);
    if (prefDescComparison != 0) {
        return prefDescComparison;
    }

    // else same score and FSN and preferred description - sort on type
    String comp1String = o1.getMatchingComponents().iterator().next().toUserString();
    String comp2String = o2.getMatchingComponents().iterator().next().toUserString();

    return ObjectUtils.compare(comp1String, comp2String);
}

From source file:de.rahn.finances.services.securities.SecuritiesServiceMetricsAspect.java

/**
 * Zhle alle geworfenen Ausnahmen.//from  w  w w . j a va 2 s . c  o  m
 */
@AfterThrowing(pointcut = "onSecuritiesService()", throwing = "exception")
public void afterThrowsException(Exception exception) {
    counterService.increment(PREFIX_METRICNAME_ERRORS);
    counterService.increment(PREFIX_METRICNAME_ERROR + exception.getClass().getSimpleName().toLowerCase());
}

From source file:com.liferay.portlet.admin.action.KillSessionAction.java

public void processAction(ActionMapping mapping, ActionForm form, PortletConfig config, ActionRequest req,
        ActionResponse res) throws Exception {

    if (!OmniadminUtil.isOmniadmin(PortalUtil.getUser(req).getUserId())) {
        SessionErrors.add(req, PrincipalException.class.getName());

        setForward(req, "portlet.admin.error");
    } else {/*  ww w  . ja va  2s  .c  o  m*/
        try {
            _killSession(req, res);
        } catch (Exception e) {
            if (e != null && e instanceof PrincipalException) {

                SessionErrors.add(req, e.getClass().getName());

                setForward(req, "portlet.admin.error");
            } else {
                req.setAttribute(PageContext.EXCEPTION, e);

                setForward(req, Constants.COMMON_ERROR);
            }
        }

        setForward(req, "portlet.admin.list_sessions");
    }
}

From source file:eu.peppol.jdbc.OxalisDataSourceFactoryDbcpImplTest.java

@Test
public void testFailWithStaleConnection() throws Exception {
    ConnectionFactory driverConnectionFactory = createConnectionFactory(false);

    GenericObjectPool genericObjectPool = new GenericObjectPool(null);
    genericObjectPool.setMaxActive(1);/*from  www. ja va 2 s. c  om*/

    PoolingDataSource poolingDataSource = createPoolingDataSource(driverConnectionFactory, genericObjectPool);
    try {
        runTwoSqlStatementsWithTwoConnections(poolingDataSource);
    } catch (Exception e) {
        assertTrue(e.getClass().getName().contains("CommunicationsException"));
    }
}

From source file:org.opendaylight.sfc.sbrest.json.RspExporterTest.java

@Test
// put wrong parameter, illegal argument exception expected
public void testExportJsonException() throws Exception {
    ServiceFunctionGroupBuilder serviceFunctionGroupBuilder = new ServiceFunctionGroupBuilder();
    RspExporter rspExporter = new RspExporter();

    try {/*w ww . j av a2  s .  c  om*/
        rspExporter.exportJson(serviceFunctionGroupBuilder.build());
    } catch (Exception exception) {
        assertEquals("Must be true", exception.getClass(), IllegalArgumentException.class);
    }

    try {
        rspExporter.exportJsonNameOnly(serviceFunctionGroupBuilder.build());
    } catch (Exception exception) {
        assertEquals("Must be true", exception.getClass(), IllegalArgumentException.class);
    }
}