当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionUtils.getRootCauseMessage方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.exception.ExceptionUtils.getRootCauseMessage方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionUtils.getRootCauseMessage方法的具体用法?Java ExceptionUtils.getRootCauseMessage怎么用?Java ExceptionUtils.getRootCauseMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.exception.ExceptionUtils的用法示例。


在下文中一共展示了ExceptionUtils.getRootCauseMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void validate(Object value) throws InvalidValueException {
	try {
		validator.validate((T) value);
	} catch (ValidationException ve) {
		throw ValidationUtils.translateValidationException(ve);
	} catch (Exception e) {
		throw new InvalidValueException("Invalid value type: " + ExceptionUtils.getRootCauseMessage(e));
	}
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:12,代码来源:ValidatorWrapper.java

示例2: prepareError

import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@Override
  public ApmError prepareError (
      final Exception ex,
      final HttpServletRequest request,
      final HttpServletResponse response) {

    final String id = generateUUID ();
    //TODO check if missing data
    final Throwable rootCause = ExceptionUtils.getRootCause (ex);
    final String rootCauseMessage = ExceptionUtils.getRootCauseMessage (ex);

    final String[] rootCauseStackTrace = ExceptionUtils.getRootCauseStackTrace (ex);
    final String culprit = rootCauseStackTrace.length > 0 ?
        rootCauseStackTrace[0] : null;

    final List<ApmStacktrace> stackTrace = new ArrayList<> ();

    for (final StackTraceElement traceElement : ex.getStackTrace ()) {
      final ApmStacktrace trace = new ApmStacktrace ()
//          .withLineno (Integer.valueOf (traceElement.getLineNumber ()).doubleValue ())
          .withAdditionalProperty ("lineno", traceElement.getLineNumber ())
          .withFilename (traceElement.getFileName ())
          .withFunction (traceElement.getMethodName ())
          .withModule (traceElement.getClassName ());
      stackTrace.add (trace);
    }

    return new ApmError ()
        .withId (id)
//        .withTimestamp (LocalDateTime.now ()) //TODO check why it isn't automatically converted to string
        .withAdditionalProperty ("timestamp", getSimpleDateFormat ().format (new Date ()))
        .withCulprit (culprit)
        .withContext (toApmContext (request, response))
        .withException (new ApmException ().withStacktrace (stackTrace).withMessage (rootCauseMessage))
        //.withLog (new ApmLog ().wi)//TODO add log
        ;
  }
 
开发者ID:davidecavestro,项目名称:elastic-apm-java-agent-poc,代码行数:38,代码来源:ApmAgent.java

示例3: UnexpectedAuthenticationException

import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
/**
 * Constructor
 * @param description Error message
 * @param cause Nested exception
 */
public UnexpectedAuthenticationException(String description, Throwable cause) {
	super(ErrorResponse.SERVER_ERROR,
			ExceptionUtils.getRootCauseMessage(cause) + ((description != null) ? (": " + description) : ""), 500);
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:10,代码来源:UnexpectedAuthenticationException.java

示例4: makeError

import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
/**
 * Creates an Error object with the root cause message from the given cause if available.
 *
 * @param cause A cause if available.
 *
 * @return An Error representing this cause.
 */
public static Error makeError(Throwable cause) {
    String message = ExceptionUtils.getRootCauseMessage(cause);
    message = message.isEmpty() ? GENERIC_JSON_ERROR : message;
    return Error.of(message, singletonList(GENERIC_JSON_RESOLUTION));
}
 
开发者ID:yahoo,项目名称:bullet-core,代码行数:13,代码来源:Error.java


注:本文中的org.apache.commons.lang3.exception.ExceptionUtils.getRootCauseMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。