本文整理汇总了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));
}
}
示例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
;
}
示例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);
}
示例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));
}