Package org.apache.sis.storage
Class DataStoreException
java.lang.Object
java.lang.Throwable
java.lang.Exception
org.apache.sis.storage.DataStoreException
- All Implemented Interfaces:
Serializable
,LocalizedException
- Direct Known Subclasses:
CanNotProbeException
,ConcurrentReadException
,ConcurrentWriteException
,DataStoreClosedException
,DataStoreContentException
,DataStoreReferencingException
,ForwardOnlyStorageException
,IllegalFeatureTypeException
,IllegalOpenParameterException
,IncompatibleResourceException
,InternalDataStoreException
,NoSuchDataException
,ReadOnlyStorageException
,ResourceAlreadyExistsException
,UnsupportedQueryException
Thrown when a
DataStore
cannot complete a read or write operation.
Localization
ThegetMessage()
and getLocalizedMessage()
methods return the same message,
but sometimes in different languages. The general policy is that getMessage()
returns
the message in the JVM default locale while getLocalizedMessage()
returns the message in the locale specified by the last call to DataStore.setLocale(Locale)
.
In a client-server architecture, the former is typically the locale of the system administrator
while the latter is presumably the locale of the client connected to the server.
However, this policy is applied on a best-effort basis only.- Since:
- 0.3
- Version:
- 0.8
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate short
The resources key as one of theResources.Keys
constant, or 0 if none.private Object[]
The parameters for the localization message, ornull
if none.private static final long
For cross-version compatibility. -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates an exception with no cause and no details message.DataStoreException
(String message) Creates an exception with the specified details message.DataStoreException
(String message, Throwable cause) Creates an exception with the specified details message and cause.DataStoreException
(Throwable cause) Creates an exception with the specified cause and no details message.(package private)
DataStoreException
(Locale locale, short key, Object... parameters) Creates a new exception which will format a localized message in the given locale.private
DataStoreException
(Locale locale, Object[] params) Workaround for RFE #4093999 ("Relax constraint on placement of this()/super() call in constructors").DataStoreException
(Locale locale, String format, String filename, Object store) Creates a localized exception with a message saying that the given store cannot be processed. -
Method Summary
Modifier and TypeMethodDescriptionorg.opengis.util.InternationalString
If this exception is capable to return the message in various locales, returns that message.Returns a localized version of the exception message, typically for final user.Returns the exception message in the default locale, typically for system administrator.Initializes the cause of this throwable to the specified value.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getStackTrace, getSuppressed, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
key
private transient short keyThe resources key as one of theResources.Keys
constant, or 0 if none.This field is not serialized because key values sometimes change between different SIS versions. The deserialized value will be 0, which will cause this
DataStoreException
to fallback onsuper.getMessage()
. -
parameters
The parameters for the localization message, ornull
if none.
-
-
Constructor Details
-
DataStoreException
public DataStoreException()Creates an exception with no cause and no details message. -
DataStoreException
Creates an exception with the specified details message.- Parameters:
message
- the detail message in the default locale.
-
DataStoreException
Creates an exception with the specified cause and no details message.- Parameters:
cause
- the cause for this exception.
-
DataStoreException
Creates an exception with the specified details message and cause.- Parameters:
message
- the detail message in the default locale.cause
- the cause for this exception.
-
DataStoreException
Creates a localized exception with a message saying that the given store cannot be processed. Location in the file where the error occurred while be fetched from the givenstore
argument if possible, for example by invoking theLineNumberReader.getLineNumber()
orXMLStreamReader.getLocation()
method. If the givenstore
argument is not one of the recognized types, then it is ignored.Examples of messages created by this constructor:
- Cannot read “Foo” as a file in the Bar format.
- Cannot read after column 10 or line 100 of “Foo” as part of a file in the Bar format.
- Parameters:
locale
- the locale of the message to be returned bygetLocalizedMessage()
, ornull
.format
- short name or abbreviation of the data format (e.g. "CSV", "GML", "WKT", etc).filename
- name of the file or data store where the error occurred.store
- the input or output object from which to get the current position, ornull
if none. This can be aLineNumberReader
orXMLStreamReader
for example.- Since:
- 0.8
-
DataStoreException
@Workaround(library="JDK", version="1.8") private DataStoreException(Locale locale, Object[] params) Workaround for RFE #4093999 ("Relax constraint on placement of this()/super() call in constructors"). -
DataStoreException
Creates a new exception which will format a localized message in the given locale.- Parameters:
locale
- the locale for the message to be returned bygetLocalizedMessage()
.key
- one ofResources.Keys
constants.parameters
- parameters to use for formatting the messages.
-
-
Method Details
-
getMessage
Returns the exception message in the default locale, typically for system administrator.- Specified by:
getMessage
in interfaceLocalizedException
- Overrides:
getMessage
in classThrowable
- Returns:
- the message of this exception.
-
getLocalizedMessage
Returns a localized version of the exception message, typically for final user. This is often the same message than the one returned bygetMessage()
, but may in some occasions be different ifDataStore.setLocale(Locale)
has been invoked with a different locale.
WhengetMessage()
versusgetLocalizedMessage()
getMessage()
andgetLocalizedMessage()
are not equivalent, the Apache SIS policy is thatgetMessage()
returns the message in the default locale whilegetLocalizedMessage()
returns the message in a locale that depends on the context in which the exception has been thrown. In a client-server architecture, the former is often the locale on the server side while the latter is the locale on the client side if that information has been provided to theDataStore
.- Specified by:
getLocalizedMessage
in interfaceLocalizedException
- Overrides:
getLocalizedMessage
in classThrowable
- Returns:
- the localized message of this exception.
- Since:
- 0.8
- See Also:
-
getInternationalMessage
public org.opengis.util.InternationalString getInternationalMessage()If this exception is capable to return the message in various locales, returns that message. Otherwise returnsnull
.- Specified by:
getInternationalMessage
in interfaceLocalizedException
- Returns:
- the exception message, or
null
if this exception cannot produce international message. - Since:
- 0.8
-
initCause
Initializes the cause of this throwable to the specified value.- Overrides:
initCause
in classThrowable
- Parameters:
cause
- the cause saved for later retrieval by theThrowable.getCause()
method.- Returns:
- a reference to this
DataStoreException
instance. - Since:
- 0.8
-