Example usage for java.lang RuntimeException getMessage

List of usage examples for java.lang RuntimeException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.vaporwarecorp.mirror.component.configuration.WebServer.java

private Response updateConfiguration(IHTTPSession session, Configuration configuration) {
    try {/*from  www.  j a va 2s  . c om*/
        final String json = getPostData(session);
        configuration.updateConfiguration(toJsonNode(json));
        return newFixedLengthResponse(null);
    } catch (RuntimeException e) {
        Timber.e(e, e.getMessage());
        return newFixedLengthResponse(INTERNAL_ERROR, MIME_PLAINTEXT, e.getMessage());
    }
}

From source file:Main.java

private void createMedia() {
    try {/*from ww  w.  ja v  a 2  s. c o  m*/
        media = new Media("http://traffic.libsyn.com/dickwall/JavaPosse373.mp3");
        media.getMetadata().addListener(new MapChangeListener<String, Object>() {
            @Override
            public void onChanged(Change<? extends String, ? extends Object> ch) {
                if (ch.wasAdded()) {
                    handleMetadata(ch.getKey(), ch.getValueAdded());
                }
            }
        });

        mediaPlayer = new MediaPlayer(media);
        mediaPlayer.setOnError(new Runnable() {
            @Override
            public void run() {
                final String errorMessage = media.getError().getMessage();
                // Handle errors during playback
                System.out.println("MediaPlayer Error: " + errorMessage);
            }
        });

        mediaPlayer.play();

    } catch (RuntimeException re) {
        // Handle construction errors
        System.out.println("Caught Exception: " + re.getMessage());
    }
}

From source file:com.hybris.integration.controller.base.ApiExceptionHandler.java

@ExceptionHandler(RuntimeException.class)
@ResponseBody/*  w ww  .  j ava  2s  .c om*/
public TmallAppResponse handleUnexpectedServerError(RuntimeException ex) {
    TmallAppResponse response = new TmallAppResponse();
    response.setCode(ResponseCode.INTERNAL_SERVER_ERROR.getCode());
    response.setMsg(ex.getClass().toString() + ":" + ex.getMessage());
    LOGGER.error(ex.getMessage(), ex);
    return response;
}

From source file:io.cloudslang.lang.tools.build.verifier.SlangContentVerifier.java

private RuntimeException wrapWithPrefix(RuntimeException rex, String prefix) {
    return new RuntimeException(prefix + rex.getMessage(), rex);
}

From source file:de.micromata.genome.gwiki.page.impl.wiki.GWikiScriptMacroFactory.java

@Override
public GWikiMacroInfo getMacroInfo() {
    GWikiMacroInfo defaultInfos = GWikiMacroFactory.super.getMacroInfo();
    ;/*from  w  ww . j a va  2  s . c o  m*/
    String mi = elementInfo.getProps().getStringValue(MACRO_MACROINFO);
    if (StringUtils.isBlank(mi) == true) {
        return defaultInfos;
    }
    try {
        JsonObject jobj = Json.parse(mi).asObject();
        MacroInfoBean ret = new MacroInfoBean();
        ret.setInfo(jobj.getString("info", ""));

        ret.setHasBody(defaultInfos.hasBody());
        ret.setEvalBody(defaultInfos.evalBody());
        ret.setRteMacro(defaultInfos.isRteMacro());

        JsonValue pv = jobj.get("macroParams");
        if (pv.isArray() == true) {
            JsonArray jarr = pv.asArray();
            for (JsonValue pi : jarr) {
                JsonObject pinf = pi.asObject();
                MacroParamInfo paramInfo = new MacroParamInfo();
                paramInfo.setName(pinf.getString("name", "unkown"));
                paramInfo.setInfo(pinf.getString("info", ""));
                paramInfo.setRequired(pinf.getBoolean("required", false));
                paramInfo.setType(MacroParamType.valueOf(pinf.getString("type", MacroParamType.String.name())));
                JsonValue enums = pinf.get("enumValues");
                if (enums != null) {
                    JsonArray ejarr = enums.asArray();
                    for (JsonValue ea : ejarr) {
                        paramInfo.getEnumValues().add(ea.asString());
                    }
                }
                ret.getParamInfos().add(paramInfo);
            }
        }
        return ret;
    } catch (RuntimeException ex) {
        GLog.error(GWikiLogCategory.Wiki, "Invalid jspon found: " + ex.getMessage(),
                new LogAttribute(GWikiLogAttributeType.PageId, elementInfo.getId()),
                new LogAttribute(GenomeAttributeType.Miscellaneous, mi), new LogExceptionAttribute(ex));
        return defaultInfos;
    }

}

From source file:com.stormpath.tooter.controller.LoginController.java

@RequestMapping(method = RequestMethod.GET, value = "/emailVerificationTokens")
public String accountVerification(@RequestParam("sptoken") String token,
        @ModelAttribute("customer") User customer, BindingResult result) {

    String returnStr = "login";

    try {/* w ww.ja  v a 2  s  . c  o  m*/

        stormpath.getTenant().verifyAccountEmail(token);
        returnStr = "redirect:/login/message?loginMsg=accVerified";

    } catch (RuntimeException re) {

        result.addError(new ObjectError("userName", re.getMessage()));
        re.printStackTrace();
    }

    return returnStr;

}

From source file:ch.tatool.core.module.initializer.SpringExecutorInitializer.java

/**
 * Checks whether a configuration xml is valid or not.
 */// ww  w . j a v a 2s  .  co m
protected Element loadRootElementFromSpringXML(String configXML) {
    // try loading the configuration
    XmlBeanFactory beanFactory = null;
    try {
        beanFactory = new XmlBeanFactory(new ByteArrayResource(configXML.getBytes()));
    } catch (BeansException be) {
        logger.error("Unable to load Tatool file.", be);
        throw new RuntimeException("Unable to load Tatool file.");
    }

    // check whether we have the mandatory beans (rootElement)
    if (!beanFactory.containsBean(ROOT_ELEMENT)) {
        logger.error("Unable to load Tatool file. Root element missing!");
        throw new CreationException("Unable to load Tatool file. Root element missing!");
    }

    // fetch the rootElement
    try {
        Element root = (Element) beanFactory.getBean(ROOT_ELEMENT);
        return root;
    } catch (RuntimeException e) {
        String[] errors = e.getMessage().split(";");
        throw new CreationException(errors[errors.length - 1]);
    }
}

From source file:com.example.app.profile.ui.user.MessageContextPropertyEditor.java

@Override
public void init() {
    super.init();

    ReflectiveAction sendAction = CommonActions.SAVE.defaultAction();
    sendAction.prop(Action.NAME, BUTTON_TEXT_SEND());

    sendAction.setActionListener(ev -> {
        if (persist(input -> {
            if (input != null) {
                return _users.stream().map(this::getUser).map(user -> {
                    switch (input.getContactMethod()) {
                    case PhoneSms:
                        try {
                            sendSms(input, user);
                        } catch (RuntimeException e) {
                            _logger.error(e.getMessage(), e);
                            getNotifiable().sendNotification(error(TextSources.createText(ERROR_PONESMS(),
                                    user.getPrincipal().getUsername())));
                            return false;
                        }/*from w  ww  .  ja va 2  s. c  o m*/
                        break;
                    case Email:
                        sendEmail(input, user);
                        break;
                    default:
                        //Shouldn't get here, but you never know.
                        break;
                    }
                    return true;
                }).noneMatch(successful -> !successful);
            }
            return false;
        })) {
            _closer.actionPerformed(ev);
        }
    });

    ReflectiveAction cancelAction = CommonActions.CANCEL.defaultAction();
    cancelAction.setActionListener(_closer);

    setPersistenceActions(sendAction, cancelAction);
}

From source file:com.gargoylesoftware.htmlunit.WebResponseDataTest.java

/**
 * Tests that broken gzipped content is handled correctly.
 * @throws Exception if the test fails/*w  w  w.j a  v a 2s. c  om*/
 */
@Test
public void brokenGZippedContent() throws Exception {
    final List<NameValuePair> headers = new ArrayList<>();
    headers.add(new NameValuePair("Content-Encoding", "gzip"));

    final WebResponseData data = new WebResponseData("Plain Content".getBytes(), HttpStatus.SC_OK, "OK",
            headers);
    try {
        data.getBody();
    } catch (final RuntimeException e) {
        assertTrue(StringUtils.contains(e.getMessage(), "Not in GZIP format"));
    }
}

From source file:ro.cornholio.vision.text.TextApp.java

@RequestMapping(method = RequestMethod.POST, value = "/ajax")
@ResponseBody//from  w w w. ja  v a2  s .  co  m
public String handleFileUpload(@RequestParam("imgBase64") String file, RedirectAttributes redirectAttributes) {
    System.out.println(file.length());
    if (!file.isEmpty()) {
        try {
            byte[] bytes = Base64.decodeBase64(file.replaceAll("data:image/.+;base64,", ""));
            List<ImageText> texts = detectText(bytes);
            System.out.println(texts.size());

            for (ImageText txt : texts) {
                System.out.println(txt.textAnnotations());

                for (EntityAnnotation annotation : txt.textAnnotations()) {
                    System.out.println(annotation.getDescription());
                }
            }

            redirectAttributes.addFlashAttribute("message", "You successfully uploaded !");
            return texts.get(0).textAnnotations().toString();
        } catch (RuntimeException e) {
            redirectAttributes.addFlashAttribute("message", "Failed to upload => " + e.getMessage());
        }
    } else {
        redirectAttributes.addFlashAttribute("message", "Failed to upload because it was empty");
    }

    return "[]";
}