FunctionException (Apache Geode 2.0.2)
Description: declaration: package: org.apache.geode.cache.execute, class: FunctionException

Package org.apache.geode.cache.execute

# Class FunctionException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.apache.geode.GemFireException
org.apache.geode.cache.execute.FunctionException

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `EmptyRegionFunctionException`, `FunctionInvocationTargetException`

public class FunctionException extends GemFireException
Thrown to indicate an error or exceptional condition during the execution of Functions in GemFire. This exception can be thrown by GemFire as well as user code, in the implementation of Function.execute(FunctionContext). When FunctionException is thrown in an implementation of Function.execute(FunctionContext), GemFire will transmit it back to, and throw it on, the calling side. For example, if a GemFire client executes a Function on a server, and the function's execute method throws a FunctionException, the server logs the exception as a warning, and transmits it back to the calling client, which throws it. This allows for separation of business and error handling logic, as client code that processes function execution results does not have to deal with errors; errors can be dealt with in the exception handling logic, by catching this exception.

The exception string provides details on the cause of failure.

Since:
  GemFire 6.0
See Also:
  - `FunctionService`
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FunctionException()`
  Creates new function exception with given error message.
  `FunctionException(String msg)`
  Creates new function exception with given error message.
  `FunctionException(String msg, Throwable cause)`
  Creates new function exception with given error message and optional nested exception.
  `FunctionException(Throwable cause)`
  Creates new function exception given throwable as a cause and source of error message.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addException(Throwable cause)`
  Adds exceptions thrown from different nodes to a ds
  `void`
  `addExceptions(Collection<? extends Throwable> ex)`
  Adds the list of exceptions provided
  `List<Throwable>`
  `getExceptions()`
  Returns the list of exceptions thrown from different nodes

  ### Methods inherited from class org.apache.geode.GemFireException

  `getRootCause`

  ### Methods inherited from class java.lang.Throwable

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

  ### Methods inherited from class java.lang.Object

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

- ## Constructor Details

  - ### FunctionException

    public FunctionException()
    Creates new function exception with given error message.
    Since:
      GemFire 6.5

  - ### FunctionException

    public FunctionException(String msg)
    Creates new function exception with given error message.
    Parameters:
      `msg` - the detail message
    Since:
      GemFire 6.0

  - ### FunctionException

    public FunctionException(String msg, Throwable cause)
    Creates new function exception with given error message and optional nested exception.
    Parameters:
      `msg` - the detail message
      `cause` - the cause
    Since:
      GemFire 6.0

  - ### FunctionException

    public FunctionException(Throwable cause)
    Creates new function exception given throwable as a cause and source of error message.
    Parameters:
      `cause` - the cause
    Since:
      GemFire 6.0

- ## Method Details

  - ### addException

    public void addException(Throwable cause)
    Adds exceptions thrown from different nodes to a ds
    Parameters:
      `cause` - The exception to add
    Since:
      GemFire 6.5

  - ### getExceptions

    public List<Throwable> getExceptions()
    Returns the list of exceptions thrown from different nodes
    Returns:
      a list of exceptions
    Since:
      GemFire 6.5

  - ### addExceptions

    public void addExceptions(Collection<? extends Throwable> ex)
    Adds the list of exceptions provided
    Parameters:
      `ex` - A collection of exceptions to be added
    Since:
      GemFire 6.5