|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Throwable
java.lang.Exception
org.fcrepo.server.errors.ServerException
public abstract class ServerException
The superclass for all Fedora server exceptions.
This class encourages the use of resource bundles as message (and detail text) sources so that localization may easily be implemented.
Methods that return text will attempt to find the message by code in the ResourceBundle, but will fall back to simply returning the code if no such message can be found in the ResourceBundle, or no such ResourceBundle exists or the bundleName given in the constructor is null.
This enables developers to temporarily construct exceptions with something like:
throw new MyException(null, "myMessageId", null, null, null);
Exceptions of this type have the benefit that they can be easily converted to informative, localized SOAP Fault envelopes.
| Constructor Summary | |
|---|---|
ServerException(String bundleName,
String code,
String[] values,
String[] details,
Throwable cause)
Constructs a new ServerException. |
|
| Method Summary | |
|---|---|
String |
getCode()
Gets the identifier for the message. |
String[] |
getDetails()
Gets any detail messages, preferring the Server locale. |
String[] |
getDetails(Locale locale)
Gets any detail messages, preferring the provided locale. |
String |
getMessage()
Gets the message, preferring the Server locale. |
String |
getMessage(Locale locale)
Gets the message, preferring the provided locale. |
void |
setWasServer()
Sets the value for the "wasServer" flag for this exception. |
boolean |
wasServer()
Tells whether the error occurred because of an unexpected error in the server, likely requiring action on the part of the server administrator. |
| Methods inherited from class java.lang.Throwable |
|---|
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ServerException(String bundleName,
String code,
String[] values,
String[] details,
Throwable cause)
bundleName - The bundle in which the message resides.code - The identifier for the message in the bundle, aka the key.values - Replacements for placeholders in the message, where placeholders
are of the form {num} where num starts at 0, indicating the 0th
(1st) item in this array.details - Identifiers for messages which provide detail on the error. This
may empty or null.cause - The underlying exception if known, null meaning unknown or none.| Method Detail |
|---|
public String getCode()
MessageBundle
for this exception.public boolean wasServer()
If it's not an error in the server, it means that the client made a mistake, which is the more likely case.
public void setWasServer()
public String getMessage()
Server locale.
getMessage in class Throwablepublic String getMessage(Locale locale)
When a message in the desired locale is not found, the locale selection logic described by the java.util.ResourceBundle class javadoc is used.
locale - The preferred locale.
public String[] getDetails()
Server locale.
public String[] getDetails(Locale locale)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||