package org.apache.commons.digester3.binder;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import static java.lang.String.format;

An error message and the context in which it occurred. Messages are usually created internally by Digester and its extensions. Messages can be created explicitly in a module using addError() statement:
try {
  bindRulesFromFile();
} catch (IOException e) {
  addError(e);
}
/** * An error message and the context in which it occurred. Messages are usually created internally by * {@code Digester} and its extensions. Messages can be created explicitly in a module using * {@link org.apache.commons.digester3.binder.RulesBinder#addError(Throwable) addError()} statement: * * <pre>try { * bindRulesFromFile(); * } catch (IOException e) { * addError(e); * }</pre> */
final class ErrorMessage {
The error message text.
/** * The error message text. */
private final String message;
The throwable that caused this message.
/** * The throwable that caused this message. */
/* @Nullable */private final Throwable cause;
Create a new ErrorMessage instance from the error message text.
Params:
  • messagePattern – The error message text pattern
  • arguments – Arguments referenced by the format specifiers in the format string
/** * Create a new {@link ErrorMessage} instance from the error message text. * * @param messagePattern The error message text pattern * @param arguments Arguments referenced by the format specifiers in the format string */
public ErrorMessage( String messagePattern, Object... arguments ) { this( format( messagePattern, arguments ), (Throwable) null ); }
Create a new ErrorMessage instance from the error message text and the related cause.
Params:
  • message – The error message text
  • cause – The throwable that caused this message
/** * Create a new {@link ErrorMessage} instance from the error message text and the related cause. * * @param message The error message text * @param cause The throwable that caused this message */
public ErrorMessage( String message, Throwable cause ) { this.message = message; this.cause = cause; }
Gets the error message text.
Returns:The error message text
/** * Gets the error message text. * * @return The error message text */
public String getMessage() { return message; }
Returns the Throwable that caused this message, or null if this message was not caused by a Throwable.
Returns:The Throwable that caused this message, or null if this message was not caused by a Throwable
/** * Returns the Throwable that caused this message, or {@code null} if this message was not caused by a Throwable. * * @return The Throwable that caused this message, or {@code null} if this message was not caused by a Throwable */
public Throwable getCause() { return cause; }
{@inheritDoc}
/** * {@inheritDoc} */
@Override public String toString() { return message; } }