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:com.bstek.dorado.idesupport.resolver.RobotResolver.java

protected void assembleError(Document document, Element responseElement, Exception error) {
    String message = error.getMessage();
    if (message == null) {
        message = error.getClass().getSimpleName();
    }/*ww w  .  j  av a 2  s  .  c  o  m*/
    Element messageElement = document.createElement("Message");
    messageElement.appendChild(document.createTextNode(message));
    responseElement.appendChild(messageElement);

    Element stackTraceElement = document.createElement("StackTrace");
    responseElement.appendChild(stackTraceElement);

    StackTraceElement[] stackTrace = error.getStackTrace();
    for (StackTraceElement ste : stackTrace) {
        Element element = document.createElement("Element");
        element.setAttribute("className", ste.getClassName());
        element.setAttribute("methodName", ste.getMethodName());
        element.setAttribute("fileName", ste.getFileName());
        element.setAttribute("lineNumber", String.valueOf(ste.getLineNumber()));
        stackTraceElement.appendChild(element);
    }
}

From source file:com.evolveum.midpoint.init.RepositoryFactory.java

public synchronized RepositoryService getCacheRepositoryService() {
    if (cacheRepositoryService == null) {
        try {/*from  w w  w.  j  a  v a 2 s .  com*/
            Class<RepositoryServiceFactory> clazz = (Class<RepositoryServiceFactory>) Class
                    .forName(REPOSITORY_FACTORY_CACHE_CLASS);
            cacheFactory = getFactoryBean(clazz);
            //TODO decompose this dependency, remove class casting !!!
            RepositoryCache repositoryCache = (RepositoryCache) cacheFactory.getRepositoryService();
            repositoryCache.setRepository(getRepositoryService(), prismContext);

            cacheRepositoryService = repositoryCache;
        } catch (Exception ex) {
            LoggingUtils.logException(LOGGER, "Failed to get cache repository service. ExceptionClass = {}", ex,
                    ex.getClass().getName());
            throw new SystemException("Failed to get cache repository service", ex);
        }
    }
    return cacheRepositoryService;
}

From source file:de.tudarmstadt.lt.lm.app.LineProbPerp.java

@SuppressWarnings("static-access")
public LineProbPerp(String args[]) {
    Options opts = new Options();

    opts.addOption(new Option("?", "help", false, "display this message"));
    opts.addOption(OptionBuilder.withLongOpt("port").withArgName("port-number").hasArg()
            .withDescription(/*from   w  ww  .j  a  va2s .c o m*/
                    String.format("Specifies the port on which the rmi registry listens (default: %d).",
                            Registry.REGISTRY_PORT))
            .create("rp"));
    opts.addOption(OptionBuilder.withLongOpt("host").withArgName("hostname").hasArg()
            .withDescription("Specifies the hostname on which the rmi registry listens (default: localhost).")
            .create("h"));
    opts.addOption(OptionBuilder.withLongOpt("file").withArgName("name").hasArg().withDescription(
            "Specify the file or directory that contains '.txt' files that are used as source for testing perplexity with the specified language model. Specify '-' to pipe from stdin. (default: '-').")
            .create("f"));
    opts.addOption(OptionBuilder.withLongOpt("out").withArgName("name").hasArg()
            .withDescription("Specify the output file. Specify '-' to use stdout. (default: '-').")
            .create("o"));
    opts.addOption(OptionBuilder.withLongOpt("name").withArgName("identifier").isRequired().hasArg()
            .withDescription("Specify the name of the language model provider that you want to connect to.")
            .create("i"));
    opts.addOption(OptionBuilder.withLongOpt("runparallel")
            .withDescription("Specify if processing should happen in parallel.").create("p"));

    try {
        CommandLine cmd = new ExtendedGnuParser(true).parse(opts, args);
        if (cmd.hasOption("help"))
            CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER, null, 0);

        _host = cmd.getOptionValue("host", "localhost");
        _rmiport = Integer.parseInt(cmd.getOptionValue("port", String.valueOf(Registry.REGISTRY_PORT)));
        _file = cmd.getOptionValue("file", "-");
        _out = cmd.getOptionValue("out", "-");
        _name = cmd.getOptionValue("name");
        _parallel = cmd.hasOption("runparallel");

    } catch (Exception e) {
        LOG.error("{}: {}- {}", _rmi_string, e.getClass().getSimpleName(), e.getMessage());
        CliUtils.print_usage_quit(System.err, getClass().getSimpleName(), opts, USAGE_HEADER,
                String.format("%s: %s%n", e.getClass().getSimpleName(), e.getMessage()), 1);
    }
    _rmi_string = String.format("rmi://%s:%d/%s", _host, _rmiport, _name);
}

From source file:net.krautchan.data.KCThread.java

public void recalc() {
    try {/*from   w w  w . j a v a  2 s. c  om*/
        Iterator<Entry<Long, KCPosting>> iter = postings.entrySet().iterator();
        if (iter.hasNext()) {
            Entry<Long, KCPosting> entry = iter.next();
            KCPosting posting = entry.getValue();
            if (null == digest) {
                makeDigest(posting);
            }
            if (null == firstPostDate) {
                firstPostDate = posting.getCreated();
            }
        }
        Assert.assertNotNull(this.getDbId());
    } catch (Exception e) {
        String trace = "Exception in KCThread " + kcNummer + " " + e.getClass().getCanonicalName() + "\n";
        for (StackTraceElement elem : e.getStackTrace()) {
            trace += " " + elem.toString() + "\n";
        }
        System.err.println(trace);
    }
}

From source file:com.acc.controller.CustomerGroupsController.java

@ResponseStatus(value = HttpStatus.BAD_REQUEST)
@ResponseBody//  w ww  . ja  va2  s  .  c om
@ExceptionHandler(InvalidCustomerGroupException.class)
public ErrorData handleCartException(final Exception excp, final HttpServletRequest request,
        final Writer writer) throws IOException {
    LOG.info("Handling Exception for this request - " + excp.getClass().getSimpleName() + " - "
            + excp.getMessage());
    if (LOG.isDebugEnabled()) {
        LOG.debug(excp);
    }
    final ErrorData errorData = handleErrorInternal(excp.getClass().getSimpleName(), excp.getMessage());
    return errorData;
}

From source file:net.pandoragames.far.ui.swing.component.MacOSXMenuAdapter.java

/**
 * Implementation of the InvocationHandler interface. 
 * @param proxy the proxy instance that the method was invoked on.
 * @param method the Method instance corresponding to the interface method invoked.
 * This is supposed to be one of the methods of class 
 * <code>com.apple.eawt.ApplicationListener</code>
 * @param args method arguments, i.e. an instance of 
 * <code>com.apple.eawt.ApplicationEvent</code>
 *///from  www .  java 2 s  . c  o m
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    String methodName = method.getName();
    logger.debug("Callback for method " + methodName + " received");
    if (validateCallParameter(methodName, args) && canHandle(methodName)) {
        try {
            EventObject osxEvent = (EventObject) args[0];
            OSXActionEvent actionEvent = new OSXActionEvent(methodName, osxEvent);
            fireOSXEvent(actionEvent);
            // mark the event object as handled
            Method setHandledMethod = osxEvent.getClass().getDeclaredMethod("setHandled",
                    new Class[] { boolean.class });
            setHandledMethod.invoke(osxEvent, new Object[] { Boolean.TRUE });
        } catch (Exception erx) {
            logger.error(erx.getClass().getName() + " handling call to method " + methodName + ": "
                    + erx.getMessage(), erx);
        }
    }
    // void methods return null
    return null;
}

From source file:com.revitasinc.sonar.dp.batch.DefectPredictionSensor.java

public void analyse(Project project, SensorContext sensorContext) {
    try {//from   w  ww . j a  va 2s  .  c  o  m
        String command = (String) project.getProperty(DefectPredictionPlugin.COMMAND);
        if (StringUtils.isBlank(command)) {
            logger.error(
                    "Please specify an SCM Command in Configuration > General Settings > Defect Prediction");
        } else {
            saveScores(project,
                    ScmLogParserFactory.getParser(command).parse(new File(getSourcePath(project)), command),
                    sensorContext,
                    doubleFromProperty(project, DefectPredictionPlugin.AUTHOR_CHANGE_WEIGHT,
                            DefectPredictionPlugin.DEFAULT_AUTHOR_CHANGE_WEIGHT),
                    doubleFromProperty(project, DefectPredictionPlugin.LINES_CHANGED_WEIGHT,
                            DefectPredictionPlugin.DEFAULT_LINES_CHANGED_WEIGHT),
                    doubleFromProperty(project, DefectPredictionPlugin.TIME_DECAY_EXPONENT,
                            DefectPredictionPlugin.DEFAULT_TIME_DECAY_EXPONENT),
                    (String) project.getProperty(DefectPredictionPlugin.FILE_NAME_REGEX),
                    (String) project.getProperty(DefectPredictionPlugin.COMMENT_REGEX));
        }
    } catch (Exception e) {
        logger.error(e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:com.vmware.identity.openidconnect.server.AuthorizationController.java

@RequestMapping(value = "/oidc/authorize/{tenant:.*}", method = { RequestMethod.GET, RequestMethod.POST })
public ModelAndView authorize(Model model, Locale locale, HttpServletRequest request,
        HttpServletResponse response, @PathVariable("tenant") String tenant) throws IOException {
    ModelAndView page = null;//ww w. j  av a  2s . c o m

    IDiagnosticsContextScope context = null;

    try {
        HttpRequest httpRequest = HttpRequest.create(request);
        context = DiagnosticsContextFactory.createContext(CorrelationID.get(httpRequest).getValue(), tenant);

        AuthenticationRequestProcessor p = new AuthenticationRequestProcessor(this.idmClient,
                this.authzCodeManager, this.sessionManager, this.messageSource, model, locale, httpRequest,
                tenant);
        Pair<ModelAndView, HttpResponse> result = p.process();
        page = result.getLeft();
        HttpResponse httpResponse = result.getRight();
        if (httpResponse != null) {
            httpResponse.applyTo(response);
        }
    } catch (Exception e) {
        logger.error("unhandled exception", e);
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                "unhandled exception: " + e.getClass().getName());
    } finally {
        if (context != null) {
            context.close();
        }
    }

    return page;
}

From source file:ca.uhn.hl7v2.model.tests.GenericCompositeTest.java

/**
 * Testing getComponent(), attempting to get components at various indexes
 *//*from  w w w . j ava 2s.  c o  m*/
@Test
public void testGetComponent() throws DataTypeException {
    class TestSpec {
        int number;
        Object outcome;
        Exception exception = null;

        TestSpec(int number, Object outcome) {
            this.number = number;
            this.outcome = outcome;
        }

        public String toString() {
            return "[ " + number + " : " + (outcome != null ? outcome : "null")
                    + (exception != null ? " [ " + exception.toString() + " ]" : " ]");
        }

        public boolean executeTest() {
            GenericComposite gc = new GenericComposite(message);
            try {
                Object retval = gc.getComponent(number);
                if (retval != null) {
                    return retval.getClass().equals(outcome);
                } else {
                    return outcome == null;
                }
            } catch (Exception e) {
                if (((Class) outcome).isAssignableFrom(e.getClass())) {
                    return true;
                } else {
                    this.exception = e;
                    return (e.getClass().equals(outcome));
                }
            }
        }
    }//inner class

    TestSpec[] tests = { new TestSpec(-1, IndexOutOfBoundsException.class), new TestSpec(0, Varies.class),
            new TestSpec(1, Varies.class), new TestSpec(2, Varies.class), new TestSpec(100, Varies.class), };

    ArrayList failedTests = new ArrayList();

    for (int i = 0; i < tests.length; i++) {
        if (!tests[i].executeTest())
            failedTests.add(tests[i]);
    }

    assertEquals("Failures: " + failedTests, 0, failedTests.size());
}

From source file:com.veterinaria.jsf.controllers.ClienteController.java

public String deleteCliente() {
    try {//  w  w  w  . j a va 2  s .c  o  m
        getClienteFacade().remove(clienteActual);
        addSuccesMessage("Eliminar Cliente", "Cliente Eliminado Exitosamente.");
        recargarLista();

    } catch (Exception e) {
        addErrorMessage("Error closing resource " + e.getClass().getName(), "Message: " + e.getMessage());

    }
    return "/faces/admin/UsuarioList";
}