Package org.tmatesoft.svn.core
Class SVNErrorMessage
- java.lang.Object
-
- org.tmatesoft.svn.core.SVNErrorMessage
-
- All Implemented Interfaces:
java.io.Serializable
public class SVNErrorMessage extends java.lang.Object implements java.io.Serializable
The SVNErrorMessage class represents error and warning messages describing reasons of exceptions occurred during runtime. An error message may be of two levels:- Error type
- Warning type
SVNErrorCode
) what gives an ability to find out what kind of an error it is.Error messages may be formatted. SVNErrorMessage performs formatting with the help of the JDK's
MessageFormat
class. To make a formatted message, useMessageFormat
parsable format patterns and provide an array of related objects when creating an SVNErrorMessage.Error messages may be supplied within exceptions of the main exception type -
SVNException
.- Since:
- 1.2
- Version:
- 1.3
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
dontShowErrorCode
private static java.lang.Object[]
EMPTY_ARRAY
private SVNErrorMessage
myChildErrorMessage
private SVNErrorCode
myErrorCode
private java.lang.String
myMessage
private java.lang.Object[]
myObjects
private java.lang.Throwable
myThrowable
private int
myType
private static long
serialVersionUID
static int
TYPE_ERROR
Error messages of this type are considered to be errors (most critical) rather than warnings.static int
TYPE_WARNING
Error messages of this type are considered to be warnings, what in certain situations may be OK.static SVNErrorMessage
UNKNOWN_ERROR_MESSAGE
This is a type of an error message denoting an error of an unknown nature.
-
Constructor Summary
Constructors Modifier Constructor Description protected
SVNErrorMessage(SVNErrorCode code, java.lang.String message, java.lang.Object[] relatedObjects, java.lang.Throwable th, int type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SVNErrorMessage
create(SVNErrorCode code)
Creates an error message given an error code.static SVNErrorMessage
create(SVNErrorCode code, java.lang.String message)
Creates an error message given an error code and description.static SVNErrorMessage
create(SVNErrorCode code, java.lang.String message, int type)
Creates an error message given an error code, description and a type ( whether it's a warning or an error).static SVNErrorMessage
create(SVNErrorCode code, java.lang.String message, java.lang.Object object)
Creates an error message given an error code, description and may be a related object to be formatted with the error description.static SVNErrorMessage
create(SVNErrorCode code, java.lang.String message, java.lang.Object... objects)
Creates an error message given an error code, description and may be related objects to be formatted with the error description.static SVNErrorMessage
create(SVNErrorCode code, java.lang.String message, java.lang.Object[] objects, int type)
Creates an error message given an error code, description, an error type (whether it's a warning or an error) and may be related objects to be formatted with the error description.static SVNErrorMessage
create(SVNErrorCode code, java.lang.String message, java.lang.Object[] objects, int type, java.lang.Throwable cause)
Creates an error message given an error code, description, an error type (whether it's a warning or an error) and may be related objects to be formatted with the error description and an optional cause.static SVNErrorMessage
create(SVNErrorCode code, java.lang.String message, java.lang.Object object, int type)
Creates an error message given an error code, description, an error type (whether it's a warning or an error) and may be a related object to be formatted with the error description.static SVNErrorMessage
create(SVNErrorCode code, java.lang.Throwable cause)
Creates an error message given an error code and cause.SVNErrorMessage
findChildWithErrorCode(SVNErrorCode errorCode)
java.lang.Throwable
getCause()
Returns throwable that is cause of the error if any.SVNErrorMessage
getChildErrorMessage()
Returns an error message (if any) that was returned from a deeper method call.SVNErrorCode
getErrorCode()
Returns the error code of the error.java.lang.String
getFullMessage()
Gets a string representation of the entire stack trace of error messages (if they were provided) starting with the initial cause of the error.java.lang.String
getMessage()
Returns an error description formatted with the related objects if needed.java.lang.String
getMessageTemplate()
Returns an error description which may contain message format patterns.java.lang.Object[]
getRelatedObjects()
Returns objects (if any) that were provided to be formatted with the error description.SVNErrorMessage
getRootErrorMessage()
Follows the children chain and returns the error message of the last child in this chain.int
getType()
Returns the type of the error (whether it's a warning or an error).boolean
hasChildErrorMessage()
Says if this error message object has got a child error message.boolean
hasChildWithErrorCode(SVNErrorCode errorCode)
void
initCause(java.lang.Throwable cause)
boolean
isDontShowErrorCode()
boolean
isErrorCodeShouldShown()
boolean
isWarning()
Returns true if this message is a warning message, not error one.void
setChildErrorMessage(SVNErrorMessage childMessage)
Sets a child error message for this one.void
setDontShowErrorCode(boolean dontShowErrorCode)
boolean
setType(int type)
Sets the type of this error message.java.lang.String
toString()
Returns a string representation of this error message object formatting (if needed) the error description with the provided related objects.SVNErrorMessage
wrap(java.lang.String parentMessage)
Wraps this error message into a new one that is returned as a parent error message.SVNErrorMessage
wrap(java.lang.String parentMessage, java.lang.Object relatedObject)
Wraps this error message into a new one that is returned as a parent error message.SVNErrorMessage
wrap(java.lang.String parentMessage, java.lang.Object[] relatedObjects)
Wraps this error message into a new one that is returned as a parent error message.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
TYPE_ERROR
public static final int TYPE_ERROR
Error messages of this type are considered to be errors (most critical) rather than warnings.- See Also:
- Constant Field Values
-
TYPE_WARNING
public static final int TYPE_WARNING
Error messages of this type are considered to be warnings, what in certain situations may be OK.- See Also:
- Constant Field Values
-
myObjects
private java.lang.Object[] myObjects
-
myMessage
private java.lang.String myMessage
-
myErrorCode
private SVNErrorCode myErrorCode
-
myType
private int myType
-
myChildErrorMessage
private SVNErrorMessage myChildErrorMessage
-
myThrowable
private java.lang.Throwable myThrowable
-
dontShowErrorCode
private boolean dontShowErrorCode
-
EMPTY_ARRAY
private static final java.lang.Object[] EMPTY_ARRAY
-
UNKNOWN_ERROR_MESSAGE
public static SVNErrorMessage UNKNOWN_ERROR_MESSAGE
This is a type of an error message denoting an error of an unknown nature. This corresponds to anSVNErrorCode.UNKNOWN
error.
-
-
Constructor Detail
-
SVNErrorMessage
protected SVNErrorMessage(SVNErrorCode code, java.lang.String message, java.lang.Object[] relatedObjects, java.lang.Throwable th, int type)
-
-
Method Detail
-
create
public static SVNErrorMessage create(SVNErrorCode code)
Creates an error message given an error code.- Parameters:
code
- an error code- Returns:
- a new error message
-
create
public static SVNErrorMessage create(SVNErrorCode code, java.lang.String message)
Creates an error message given an error code and description.- Parameters:
code
- an error codemessage
- an error description- Returns:
- a new error message
-
create
public static SVNErrorMessage create(SVNErrorCode code, java.lang.Throwable cause)
Creates an error message given an error code and cause.- Parameters:
code
- an error codecause
- cause of the error- Returns:
- a new error message
-
create
public static SVNErrorMessage create(SVNErrorCode code, java.lang.String message, java.lang.Object object)
Creates an error message given an error code, description and may be a related object to be formatted with the error description. To format the providedobject
with themessage
, you should use valid format patterns parsable forMessageFormat
.- Parameters:
code
- an error codemessage
- an error descriptionobject
- an object related to the errormessage
- Returns:
- a new error message
-
create
public static SVNErrorMessage create(SVNErrorCode code, java.lang.String message, java.lang.Object... objects)
Creates an error message given an error code, description and may be related objects to be formatted with the error description. To format the providedobjects
with themessage
, you should use valid format patterns parsable forMessageFormat
.- Parameters:
code
- an error codemessage
- an error descriptionobjects
- an array of objects related to the errormessage
- Returns:
- a new error message
-
create
public static SVNErrorMessage create(SVNErrorCode code, java.lang.String message, int type)
Creates an error message given an error code, description and a type ( whether it's a warning or an error).- Parameters:
code
- an error codemessage
- an error descriptiontype
- an error type- Returns:
- a new error message
-
create
public static SVNErrorMessage create(SVNErrorCode code, java.lang.String message, java.lang.Object object, int type)
Creates an error message given an error code, description, an error type (whether it's a warning or an error) and may be a related object to be formatted with the error description. To format the providedobject
with themessage
, you should use valid format patterns parsable forMessageFormat
.- Parameters:
code
- an error codemessage
- an error descriptionobject
- an object related to the errormessage
type
- an error type- Returns:
- a new error message
-
create
public static SVNErrorMessage create(SVNErrorCode code, java.lang.String message, java.lang.Object[] objects, int type)
Creates an error message given an error code, description, an error type (whether it's a warning or an error) and may be related objects to be formatted with the error description. To format the providedobjects
with themessage
, you should use valid format patterns parsable forMessageFormat
.- Parameters:
code
- an error codemessage
- an error descriptionobjects
- an array of objects related to the errormessage
type
- an error type- Returns:
- a new error message
-
create
public static SVNErrorMessage create(SVNErrorCode code, java.lang.String message, java.lang.Object[] objects, int type, java.lang.Throwable cause)
Creates an error message given an error code, description, an error type (whether it's a warning or an error) and may be related objects to be formatted with the error description and an optional cause. To format the providedobjects
with themessage
, you should use valid format patterns parsable forMessageFormat
.- Parameters:
code
- an error codemessage
- an error descriptionobjects
- an array of objects related to the errormessage
type
- an error typecause
- cause of the error- Returns:
- a new error message
-
getType
public int getType()
Returns the type of the error (whether it's a warning or an error).- Returns:
- the type of this error message
-
getErrorCode
public SVNErrorCode getErrorCode()
Returns the error code of the error.- Returns:
- th error code of the error
-
getMessage
public java.lang.String getMessage()
Returns an error description formatted with the related objects if needed. This call is equivalent to a call totoString()
- Returns:
- an error message
-
getFullMessage
public java.lang.String getFullMessage()
Gets a string representation of the entire stack trace of error messages (if they were provided) starting with the initial cause of the error.- Returns:
- a string representing a full list of error messages
-
getMessageTemplate
public java.lang.String getMessageTemplate()
Returns an error description which may contain message format patterns.- Returns:
- an error description
-
getRelatedObjects
public java.lang.Object[] getRelatedObjects()
Returns objects (if any) that were provided to be formatted with the error description. Objects are formatted by the standardMessageFormat
engine.- Returns:
- an array of objects
-
getChildErrorMessage
public SVNErrorMessage getChildErrorMessage()
Returns an error message (if any) that was returned from a deeper method call. So the topmost error messages have the entire chain of error messages down to the real error cause.- Returns:
- a child error message object (if this object is not the first one)
-
hasChildErrorMessage
public boolean hasChildErrorMessage()
Says if this error message object has got a child error message.- Returns:
- true if has, false otherwise (for example, an initial error message would not have a child error message)
-
getCause
public java.lang.Throwable getCause()
Returns throwable that is cause of the error if any.- Returns:
- throwable that caused error or null if not applicable or not known.
-
toString
public java.lang.String toString()
Returns a string representation of this error message object formatting (if needed) the error description with the provided related objects. If no error description pattern has been provided, the return value includes a string representation of the error code (seeSVNErrorCode
).- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representing this object.
-
isErrorCodeShouldShown
public boolean isErrorCodeShouldShown()
-
setChildErrorMessage
public void setChildErrorMessage(SVNErrorMessage childMessage)
Sets a child error message for this one.- Parameters:
childMessage
- a child error message
-
wrap
public SVNErrorMessage wrap(java.lang.String parentMessage)
Wraps this error message into a new one that is returned as a parent error message. A parent message is set the error code of this error message, a new error description and this error message as its child.- Parameters:
parentMessage
- a parent error description- Returns:
- a parent error message
-
wrap
public SVNErrorMessage wrap(java.lang.String parentMessage, java.lang.Object relatedObject)
Wraps this error message into a new one that is returned as a parent error message. A parent message is set the error code of this error message, a new error description and this error message as its child.- Parameters:
parentMessage
- a parent error descriptionrelatedObject
- an object to be formatted withparentMessage
- Returns:
- a parent error message
-
wrap
public SVNErrorMessage wrap(java.lang.String parentMessage, java.lang.Object[] relatedObjects)
Wraps this error message into a new one that is returned as a parent error message. A parent message is set the error code of this error message, a new error descriptionparentMessage
with correspondingrelatedObjects
to format the error description, and this error message as its child.- Parameters:
parentMessage
- a parent error descriptionrelatedObjects
- objects to be formatted withparentMessage
- Returns:
- a parent error message
-
isWarning
public boolean isWarning()
Returns true if this message is a warning message, not error one.- Returns:
- true if this error message
is of type
TYPE_WARNING
} and false otherwise
-
setType
public boolean setType(int type)
Sets the type of this error message.type
must be eitherTYPE_ERROR
orTYPE_WARNING
. This method is intended for inner (within internals) purposes only and must not be used by API users.- Parameters:
type
- error message type- Returns:
- true if the type of this error message is changed, false if the type passed is not recognized and thus ignored
-
getRootErrorMessage
public SVNErrorMessage getRootErrorMessage()
Follows the children chain and returns the error message of the last child in this chain. Starts withgetChildErrorMessage()
.- Returns:
- error message of the last element in the children chain
-
isDontShowErrorCode
public boolean isDontShowErrorCode()
-
setDontShowErrorCode
public void setDontShowErrorCode(boolean dontShowErrorCode)
-
findChildWithErrorCode
public SVNErrorMessage findChildWithErrorCode(SVNErrorCode errorCode)
-
hasChildWithErrorCode
public boolean hasChildWithErrorCode(SVNErrorCode errorCode)
-
initCause
public void initCause(java.lang.Throwable cause)
-
-