Module org.apache.sis.referencing
Package org.apache.sis.referencing.factory

# Class UnavailableFactoryException

Object
Throwable
Exception
FactoryException
MissingFactoryResourceException
UnavailableFactoryException

All Implemented Interfaces:
  `Serializable`

public class UnavailableFactoryException extends MissingFactoryResourceException
Thrown when a whole factory cannot be created because a resource is missing. The most common case is when the `EPSGFactory` has no connection to an EPSG database.

## Relationship with other exceptions

This exception means that the whole factory is unusable. By contrast, `MissingFactoryResourceException` means that at least one particular object cannot be created, but other objects may be okay.

Since:
  0.7
See Also:
  - `ConcurrentAuthorityFactory​.newDataAccess()`
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `UnavailableFactoryException()`
  Construct an exception with no detail message.
  `UnavailableFactoryException(String message)`
  Construct an exception with the specified detail message.
  `UnavailableFactoryException(String message, Throwable cause)`
  Construct an exception with the specified detail message and cause.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `AuthorityFactory`
  `getUnavailableFactory()`
  Returns the factory which has been found unavailable, or `null` if unspecified.
  `void`
  `setUnavailableFactory(AuthorityFactory factory)`
  Specifies which factory is unavailable.

  ### Methods inherited from class Throwable

  `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### UnavailableFactoryException

    public UnavailableFactoryException()
    Construct an exception with no detail message.

  - ### UnavailableFactoryException

    public UnavailableFactoryException(String message)
    Construct an exception with the specified detail message.
    Parameters:
      `message` - the detail message. The detail message is saved for later retrieval by the `Throwable​.getMessage()` method.

  - ### UnavailableFactoryException

    public UnavailableFactoryException(String message, Throwable cause)
    Construct an exception with the specified detail message and cause. The cause is the exception thrown in the underlying database (e.g. `IOException` or `SQLException`).
    Parameters:
      `message` - the detail message. The detail message is saved for later retrieval by the `Throwable​.getMessage()` method.
      `cause` - the cause for this exception. The cause is saved for later retrieval by the `Throwable​.getCause()` method.

- ## Method Details

  - ### setUnavailableFactory

    public void setUnavailableFactory(AuthorityFactory factory)
    Specifies which factory is unavailable. This information can be provided when the exception occurred at some later stage after the factory construction (never inside the factory constructor), for example the first time that the factory tried to create an object.

    #### Example

    `EPSGFactory` may have been successfully created with a valid `DataSource`. But the call to `DataSource​.getConnection()` happens only later (the first time that user invokes a method requiring a search in the database). In case of failure to connect to the database, user may discover late that the factory is actually unavailable. User may want to be informed about which factory is unavailable, for example in order to remove it from the list of factory managed by `MultiAuthoritiesFactory`.
    Parameters:
      `factory` - the factory which is unavailable.

  - ### getUnavailableFactory

    public AuthorityFactory getUnavailableFactory()
    Returns the factory which has been found unavailable, or `null` if unspecified. See `setUnavailableFactory(AuthorityFactory)` for more details.
    Returns:
      the factory that should be considered as unavailable.