/** * Creates or passes through a MessageFormatException to be thrown to the client. * * In the event that the exception passed to this method is already a * MessageFormatException it is passed through unmodified, otherwise a new * MessageFormatException is created using the error message taken from the * given Throwable value and the cause value is set to the given Throwable * instance. * * @param cause * The exception that caused this error state. * * @return a MessageEOFException instance. */publicstatic MessageFormatException createMessageFormatException(Throwable cause) {
String message = cause.getMessage();
if (message == null || message.length() == 0) {
message = cause.toString();
}
MessageFormatException exception = new MessageFormatException(message);
if (cause instanceof Exception) {
exception.setLinkedException((Exception) cause);
}
exception.initCause(cause);
return exception;
}

/** * Creates or passes through a MessageFormatException to be thrown to the client. * * In the event that the exception passed to this method is already a * MessageFormatException it is passed through unmodified, otherwise a new * MessageFormatException is created using the error message taken from the * given Throwable value and the cause value is set to the given Throwable * instance. * * @param cause * The exception that caused this error state. * * @return a MessageEOFException instance. */publicstatic MessageFormatException createMessageFormatException(Throwable cause) {
String message = cause.getMessage();
if (message == null || message.length() == 0) {
message = cause.toString();
}
MessageFormatException exception = new MessageFormatException(message);
if (cause instanceof Exception) {
exception.setLinkedException((Exception) cause);
}
exception.initCause(cause);
return exception;
}

/** * Creates or passes through a MessageFormatException to be thrown to the client. * * In the event that the exception passed to this method is already a * MessageFormatException it is passed through unmodified, otherwise a new * MessageFormatException is created using the error message taken from the * given Throwable value and the cause value is set to the given Throwable * instance. * * @param cause * The exception that caused this error state. * * @return a MessageEOFException instance. */publicstatic MessageFormatException createMessageFormatException(Throwable cause) {
String message = cause.getMessage();
if (message == null || message.length() == 0) {
message = cause.toString();
}
MessageFormatException exception = new MessageFormatException(message);
if (cause instanceof Exception) {
exception.setLinkedException((Exception) cause);
}
exception.initCause(cause);
return exception;
}

Coding smarter using AI

"With so much code out there, many of the problems developers face are already solved. Codota trains on open source code and automatically completes best practice code in the IDE"