# PrivilegedActionException

public class **PrivilegedActionException** extends [Exception](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Exception.html)  
Legacy security code; do not use.

This exception is thrown by
`doPrivileged(PrivilegedExceptionAction)` and
`doPrivileged(PrivilegedExceptionAction,
AccessControlContext context)` to indicate
that the action being performed threw a checked exception. The exception
thrown by the action can be obtained by calling the
`getException` method. In effect, an
`PrivilegedActionException` is a "wrapper"
for an exception thrown by a privileged action.

As of release 1.4, this exception has been retrofitted to conform to
the general purpose exception-chaining mechanism. The "exception thrown
by the privileged computation" that is provided at construction time and
accessed via the `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedActionException.html#getException()` method is now known as the
*cause*, and may be accessed via the `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getCause()`
method, as well as the aforementioned "legacy method."

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedExceptionAction.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AccessController.html#doPrivileged(java.security.PrivilegedExceptionAction<T>)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AccessController.html#doPrivileged(java.security.PrivilegedExceptionAction<T>,%20java.security.AccessControlContext)`

### Public Constructor Summary

|---|---|
|   | [PrivilegedActionException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedActionException.html#PrivilegedActionException(java.lang.Exception))([Exception](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Exception.html) exception) Constructs a new PrivilegedActionException "wrapping" the specific Exception. |

### Public Method Summary

|---|---|
| [Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) | [getCause](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedActionException.html#getCause())() Returns the cause of this exception (the exception thrown by the privileged computation that resulted in this `PrivilegedActionException`). |
| [Exception](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Exception.html) | [getException](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedActionException.html#getException())() Returns the exception thrown by the privileged computation that resulted in this `PrivilegedActionException`. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedActionException.html#toString())() Returns a short description of this throwable. |

### Inherited Method Summary

From class [java.lang.Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html)

|---|---|
| synchronized final void | [addSuppressed](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#addSuppressed(java.lang.Throwable))([Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) exception) Appends the specified exception to the exceptions that were suppressed in order to deliver this exception. |
| synchronized [Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) | [fillInStackTrace](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#fillInStackTrace())() Fills in the execution stack trace. |
| synchronized [Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) | [getCause](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getCause())() Returns the cause of this throwable or `null` if the cause is nonexistent or unknown. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getLocalizedMessage](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getLocalizedMessage())() Creates a localized description of this throwable. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getMessage](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getMessage())() Returns the detail message string of this throwable. |
| StackTraceElement\[\] | [getStackTrace](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getStackTrace())() Provides programmatic access to the stack trace information printed by `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#printStackTrace()`. |
| synchronized final [Throwable\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) | [getSuppressed](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getSuppressed())() Returns an array containing all of the exceptions that were suppressed, typically by the `try`-with-resources statement, in order to deliver this exception. |
| synchronized [Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) | [initCause](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#initCause(java.lang.Throwable))([Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html) cause) Initializes the *cause* of this throwable to the specified value. |
| void | [printStackTrace](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#printStackTrace())() Prints this throwable and its backtrace to the standard error stream. |
| void | [printStackTrace](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#printStackTrace(java.io.PrintWriter))([PrintWriter](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintWriter.html) s) Prints this throwable and its backtrace to the specified print writer. |
| void | [printStackTrace](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#printStackTrace(java.io.PrintStream))([PrintStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/PrintStream.html) s) Prints this throwable and its backtrace to the specified print stream. |
| void | [setStackTrace](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#setStackTrace(java.lang.StackTraceElement[]))(StackTraceElement\[\] stackTrace) Sets the stack trace elements that will be returned by `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getStackTrace()` and printed by `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#printStackTrace()` and related methods. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#toString())() Returns a short description of this throwable. |

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Public Constructors

#### public
**PrivilegedActionException**
([Exception](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Exception.html) exception)

Constructs a new PrivilegedActionException "wrapping"
the specific Exception.

##### Parameters

| exception | The exception thrown |
|---|---|

## Public Methods

#### public [Throwable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html)
**getCause**
()

Returns the cause of this exception (the exception thrown by
the privileged computation that resulted in this
`PrivilegedActionException`).

##### Returns

- the cause of this exception.

#### public [Exception](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Exception.html)
**getException**
()

Returns the exception thrown by the privileged computation that
resulted in this `PrivilegedActionException`.

This method predates the general-purpose exception chaining facility.
The `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getCause()` method is now the preferred means of
obtaining this information.

##### Returns

- the exception thrown by the privileged computation that resulted in this `PrivilegedActionException`.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/PrivilegedExceptionAction.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AccessController.html#doPrivileged(java.security.PrivilegedExceptionAction<T>)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AccessController.html#doPrivileged(java.security.PrivilegedExceptionAction<T>,%20java.security.AccessControlContext)`

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**toString**
()

Returns a short description of this throwable.
The result is the concatenation of:

- the {@linkplain Class#getName() name} of the class of this object
- ": " (a colon and a space)
- the result of invoking this object's `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Throwable.html#getLocalizedMessage()` method

If `getLocalizedMessage` returns `null`, then just the class name is returned.

<br />

##### Returns

- a string representation of this throwable.