Example usage for org.springframework.core NestedExceptionUtils buildMessage

List of usage examples for org.springframework.core NestedExceptionUtils buildMessage

Introduction

In this page you can find the example usage for org.springframework.core NestedExceptionUtils buildMessage.

Prototype

@Nullable
public static String buildMessage(@Nullable String message, @Nullable Throwable cause) 

Source Link

Document

Build a message for the given base message and root cause.

Usage

From source file:org.shept.persistence.UnsupportedModelTransformation.java

public UnsupportedModelTransformation(Object rowModel) {
    super(NestedExceptionUtils.buildMessage(
            "The row " + rowModel.toString() + " cannot be converted into a persistable model object", null));
}

From source file:org.craftercms.deployer.api.exceptions.DeploymentException.java

/**
 * Return the detail message, including the message from the nested exception if there is one.
 *//*from www.  java2  s .  c o m*/
@Override
public String getMessage() {
    return NestedExceptionUtils.buildMessage(super.getMessage(), getCause());
}

From source file:fr.xebia.springframework.jms.support.converter.JaxbMessageConverterTibjmsImpl.java

/**
 * @throws MessageConversionException/*  ww  w  .  j  a  v a  2s. com*/
 *             if a problem occurs loading {@link com.tibco.tibjms.Tibjms#setMessageEncodingMethod} method.
 */
public JaxbMessageConverterTibjmsImpl() {
    super();
    try {
        Class<?> tibJmsClass = Class.forName(TIBJMS_CLASS);

        this.setMessageEncodingMethod = tibJmsClass.getMethod(TIBJMS_SET_MESSAGE_ENCODING_METHOD,
                new Class[] { Message.class, String.class });
    } catch (Exception e) {
        throw new MessageConversionException(
                NestedExceptionUtils.buildMessage("Exception loading Tibjms class", e), e);
    }
}

From source file:fr.xebia.springframework.jms.support.converter.JaxbMessageConverterTibjmsImpl.java

/**
 * Set given <code>message</code> encoding with Tibco proprietary APIs.
 * /*from   ww  w  .j ava  2 s  .c o m*/
 * @see com.tibco.tibjms.Tibjms#setMessageEncoding(javax.jms.Message, String)
 * @see fr.xebia.springframework.jms.support.converter.JaxbMessageConverter#postProcessResponseMessage(Message)
 */
@Override
protected void postProcessResponseMessage(Message textMessage) throws JMSException {
    super.postProcessResponseMessage(textMessage);
    String encoding = this.marshallerProperties == null ? null
            : (String) this.marshallerProperties.get(Marshaller.JAXB_ENCODING);

    encoding = encoding == null ? "UTF-8" : encoding;
    try {
        this.setMessageEncodingMethod.invoke(null, new Object[] { textMessage, encoding });
    } catch (Exception e) {
        MessageConversionException jmse = new MessageConversionException(
                NestedExceptionUtils.buildMessage("Exception setting message encoding", e), e);
        throw jmse;
    }
}

From source file:com.iflytek.edu.cloud.frame.spring.DefaultHandlerExceptionResolver.java

@Override
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response,
        Object handler, Exception ex) {
    response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

    MainError mainError = null;/*from   www .  j  a v a  2 s . c  o m*/

    Locale locale = (Locale) request.getAttribute(Constants.SYS_PARAM_KEY_LOCALE);
    try {
        if (ex instanceof BindException) {
            mainError = handleBindException((BindException) ex, request, response, handler);
        } else if (ex instanceof MissingParamException) {
            MissingParamException _exception = (MissingParamException) ex;
            mainError = SubErrors.getMainError(SubErrorType.ISV_MISSING_PARAMETER, locale);

            SubError subError = SubErrors.getSubError(SubErrorType.ISV_MISSING_PARAMETER.value(), locale,
                    _exception.getParamName(), _exception.getMessage());
            mainError.addSubError(subError);

        } else if (ex instanceof InvalidParamException) {
            InvalidParamException _exception = (InvalidParamException) ex;
            mainError = SubErrors.getMainError(SubErrorType.ISV_INVALID_PARAMETER, locale);

            SubError subError = SubErrors.getSubError(SubErrorType.ISV_INVALID_PARAMETER.value(), locale,
                    _exception.getParamName(), _exception.getValue(), _exception.getMessage());
            mainError.addSubError(subError);

        } else if (ex instanceof CycoreErrorException) {
            CycoreErrorException _exception = (CycoreErrorException) ex;
            mainError = SubErrors.getMainError(SubErrorType.ISV_CYCORE_ERROR, locale);

            SubError subError = SubErrors.getSubError(SubErrorType.ISV_CYCORE_ERROR.value(), locale,
                    _exception.getErrorMessage(), _exception.getMessage());
            mainError.addSubError(subError);

        } else if (ex instanceof TypeMismatchException) {
            TypeMismatchException _exception = (TypeMismatchException) ex;

            mainError = SubErrors.getMainError(SubErrorType.ISV_PARAMETERS_MISMATCH, locale);
            SubErrorType tempSubErrorType = SubErrorType.ISV_PARAMETERS_MISMATCH;
            SubError subError = SubErrors.getSubError(tempSubErrorType.value(), locale, _exception.getValue(),
                    _exception.getRequiredType().getSimpleName());
            mainError.addSubError(subError);
        } else {
            SubError subError = SubErrors.getSubError(SubErrorType.ISP_SERVICE_UNAVAILABLE.value(),
                    (Locale) request.getAttribute(Constants.SYS_PARAM_KEY_LOCALE),
                    request.getParameter(Constants.SYS_PARAM_KEY_METHOD),
                    NestedExceptionUtils.buildMessage(ex.getMessage(), ex));

            mainError = MainErrors.getError(MainErrorType.SERVICE_CURRENTLY_UNAVAILABLE,
                    (Locale) request.getAttribute(Constants.SYS_PARAM_KEY_LOCALE));
            mainError.addSubError(subError);
        }

        request.setAttribute(Constants.MAIN_ERROR_CODE, mainError.getCode());
        messageConverter.convertData(request, response, mainError);

        logger.warn(ex.getMessage(), ex);
    } catch (Exception handlerException) {
        logger.warn("Handling of [" + ex.getClass().getName() + "] resulted in Exception", handlerException);
    }

    return ERROR_MODEL_AND_VIEW;
}