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:monasca.log.api.app.LogServiceTest.java

public void testValidate_shouldFail_ApplicationType_TooLarge() {
    final String str = TestUtils.generateRandomStr(LogApiConstants.MAX_NAME_LENGTH + new Random().nextInt(10));
    try {// ww w  . j a v a2 s .  co m
        final Log log = new Log(str, null, null);
        this.logService.validate(log);
    } catch (Exception exp) {
        Assert.assertTrue(WebApplicationException.class.isAssignableFrom(exp.getClass()));
        return;
    }
    Assert.fail("Should fail for invalid error message");
}

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

/**
 * {@inheritDoc}// www  .java2  s  .c om
 */
public void operationStarted(OperationType type) {
    for (ComponentContainer comp : startComponents) {
        if ((comp.type == type) || (comp.type == OperationType.ANY)) {
            try {
                SwingUtilities.invokeAndWait(new EnDisableComponent(comp.component, comp.endisFlag));
            } catch (Exception itx) {
                logger.error(itx.getClass().getName() + " notifying " + comp.component.getName() + " ("
                        + comp.component.getClass().getName() + "): " + itx.getMessage(), itx);
            }
        }
    }
}

From source file:org.easysoa.registry.dbb.rest.ServiceFinderRest.java

private String formatError(Exception e) {
    return e.getClass().getSimpleName() + ": " + e.getMessage();
}

From source file:com.microsoft.alm.plugin.idea.common.starters.ApplicationStarterBase.java

@Override
public void main(String[] args) {
    logger.debug("Args passed to VSTS to process: {}", Arrays.toString(args));
    try {/*from  w w  w  . ja v  a2  s  .co  m*/
        if (StringUtils.startsWithIgnoreCase(args[1], URI_PREFIX)) {
            // pass the uri but after removing it's prefix since it isn't needed anymore
            processUri(args[1].replaceFirst(URI_PREFIX, StringUtils.EMPTY));
        } else {
            List<String> argsList = new ArrayList<String>(Arrays.asList(args));
            // remove first arg which is just the generic command "vsts" that got us to this point
            argsList.remove(0);
            processCommand(argsList);
        }
    } catch (Exception e) {
        logger.error(TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_ERRORS_UNEXPECTED, e.getMessage()));
        logMetrics(false, e.getClass().getSimpleName());
        saveAll();

        // exit code IntelliJ uses for exceptions
        System.exit(1);
    } catch (Throwable t) {
        logger.error(TfPluginBundle.message(TfPluginBundle.KEY_CHECKOUT_ERRORS_UNEXPECTED, t.getMessage()));
        logMetrics(false, t.getClass().getSimpleName());
        saveAll();

        // exit code IntelliJ uses for throwables
        System.exit(2);
    }

    // log metrics and save settings before IDE closes
    logMetrics(true, null);
    saveAll();
}

From source file:it.smartcommunitylab.aac.controller.BasicProfileController.java

@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Exception.class)
@ResponseBody//from  www  .j  ava2s .  c  om
ErrorInfo handleBadRequest(HttpServletRequest req, Exception ex) {
    StackTraceElement ste = ex.getStackTrace()[0];
    return new ErrorInfo(req.getRequestURL().toString(), ex.getClass().getTypeName(), ste.getClassName(),
            ste.getLineNumber());
}

From source file:com.sg.rest.controllers.RestErrorHandler.java

@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody/* www . j  a  v a 2 s  .  c  o  m*/
public ServerException processException(Exception ex) throws Exception {

    ServerException dto = new ServerException();
    LOGGER.error("Rest exception occured " + dto.getEventRef().getId() + ": ", ex);

    if (AnnotationUtils.findAnnotation(ex.getClass(), ResponseStatus.class) != null) {
        throw ex;
    }

    return dto;
}

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

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

    try {/*from ww w .j  a va  2  s . c  om*/
        sfExporter.exportJson(serviceFunctionGroupBuilder.build());
    } catch (Exception exception) {
        assertEquals("Must be true", exception.getClass(), IllegalArgumentException.class);
    }

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

From source file:com.twinsoft.convertigo.beans.steps.WriteBase64Step.java

protected void writeFile(String filePath, NodeList nodeList) throws EngineException {
    if (nodeList == null) {
        throw new EngineException("Unable to write to xml file: element is Null");
    }/*from   w w  w.ja v a 2 s  .c o m*/

    String fullPathName = getAbsoluteFilePath(filePath);
    synchronized (Engine.theApp.filePropertyManager.getMutex(fullPathName)) {
        try {
            for (Node node : XMLUtils.toNodeArray(nodeList)) {
                try {
                    String content = node instanceof Element ? ((Element) node).getTextContent()
                            : node.getNodeValue();
                    if (content != null && content.length() > 0) {
                        byte[] bytes = Base64.decodeBase64(content);
                        if (bytes != null && bytes.length > 0) {
                            FileUtils.writeByteArrayToFile(new File(fullPathName), bytes);
                            return;
                        }
                    }
                } catch (Exception e) {
                    Engine.logBeans.info("(WriteBase64Step) Failed to decode and write base64 content : "
                            + e.getClass().getCanonicalName());
                }
            }
        } finally {
            Engine.theApp.filePropertyManager.releaseMutex(fullPathName);
        }
    }
}

From source file:org.atomserver.core.validators.RelaxNGValidator.java

public void validate(String contentXML) throws BadContentException {
    // null content is inherently invalid
    if (contentXML == null) {
        throw new BadContentException("Invalid Content: content is null");
    }/*from   w  ww.j a v a  2 s.co  m*/

    // otherwise, try to validate the content against the validation driver, and throw a
    // BadContentException if it fails
    try {
        validationDriver.get().validate(new InputSource(new StringReader(contentXML)));
    } catch (Exception e) {
        int numChars = (contentXML.length() < CHARS_TO_OUTPUT) ? contentXML.length() : CHARS_TO_OUTPUT;
        String msg = "Document invalid - " + e.getClass().getName() + " message= " + e.getMessage()
                + "\n The first 100 chars of the document:: " + contentXML.substring(0, numChars);
        throw new BadContentException(msg, e);
    }
}

From source file:org.springframework.cloud.cloudfoundry.discovery.CloudFoundryDiscoveryClient.java

@Override
public ServiceInstance getLocalServiceInstance() {
    List<ServiceInstance> serviceInstances = null;
    try {/*from  w  w w  .  j  av a  2  s  .c  o m*/
        CloudApplication application = this.cloudFoundryClient.getApplication(this.vcapApplicationName);
        serviceInstances = this
                .createServiceInstancesFromCloudApplications(Collections.singletonList(application));
    } catch (Exception e) {
        log.warn("Could not determine local service instance: " + e.getClass() + " (" + e.getMessage() + ")");
    }
    return serviceInstances != null && serviceInstances.size() > 0 ? serviceInstances.iterator().next() : null;
}