IT. Expert System.

Android Reference

Throwable


java.lang

Class Throwable

  • All Implemented Interfaces:
    Serializable
    Direct Known Subclasses:
    Error, Exception


    public class Throwable
    extends Object
    implements Serializable
    The superclass of all classes which can be thrown by the VM. The two direct subclasses are recoverable exceptions (Exception) and unrecoverable errors (Error). This class provides common methods for accessing a string message which provides extra information about the circumstances in which the Throwable was created (basically an error message in most cases), and for saving a stack trace (that is, a record of the call stack at a particular point in time) which can be printed later.

    A Throwable can also include a cause, which is a nested Throwable that represents the original problem that led to this Throwable. It is often used for wrapping various types of errors into a common Throwable without losing the detailed original error information. When printing the stack trace, the trace of the cause is included.

    See Also:
    Error, Exception, RuntimeException, Serialized Form
    • Constructor Summary

      Constructors
      Modifier Constructor and Description
      Throwable()
      Constructs a new Throwable that includes the current stack trace.
      Throwable(String detailMessage)
      Constructs a new Throwable with the current stack trace and the specified detail message.
      Throwable(String detailMessage, Throwable throwable)
      Constructs a new Throwable with the current stack trace, the specified detail message and the specified cause.
      protected Throwable(String detailMessage, Throwable throwable, boolean enableSuppression)
      Constructs a new Throwable with the current stack trace, the specified detail message and the specified cause.
      Throwable(Throwable throwable)
      Constructs a new Throwable with the current stack trace and the specified cause.
    • Constructor Detail

      • Throwable

        public Throwable()
        Constructs a new Throwable that includes the current stack trace.
      • Throwable

        public Throwable(String detailMessage)
        Constructs a new Throwable with the current stack trace and the specified detail message.
        Parameters:
        detailMessage - the detail message for this Throwable.
      • Throwable

        public Throwable(String detailMessage,
                 Throwable throwable)
        Constructs a new Throwable with the current stack trace, the specified detail message and the specified cause.
        Parameters:
        detailMessage - the detail message for this Throwable.
        throwable - the cause of this Throwable.
      • Throwable

        public Throwable(Throwable throwable)
        Constructs a new Throwable with the current stack trace and the specified cause.
        Parameters:
        throwable - the cause of this Throwable.
      • Throwable

        protected Throwable(String detailMessage,
                 Throwable throwable,
                 boolean enableSuppression)
        Constructs a new Throwable with the current stack trace, the specified detail message and the specified cause.
        Parameters:
        enableSuppression - if false, throwables passed to addSuppressed(Throwable) will be silently discarded.
        Since:
        1.7
    • Method Detail

      • fillInStackTrace

        public Throwable fillInStackTrace()
        Records the stack trace from the point where this method has been called to this Throwable. This method is invoked by the Throwable constructors.

        This method is public so that code (such as an RPC system) which catches a Throwable and then re-throws it can replace the construction-time stack trace with a stack trace from the location where the exception was re-thrown, by calling fillInStackTrace.

        This method is non-final so that non-Java language implementations can disable VM stack traces for their language. Filling in the stack trace is relatively expensive. Overriding this method in the root of a language's exception hierarchy allows the language to avoid paying for something it doesn't need.

        Returns:
        this Throwable instance.
      • getMessage

        public String getMessage()
        Returns the extra information message which was provided when this Throwable was created. Returns null if no message was provided at creation time.
        Returns:
        this Throwable's detail message.
      • getLocalizedMessage

        public String getLocalizedMessage()
        Returns the extra information message which was provided when this Throwable was created. Returns null if no message was provided at creation time. Subclasses may override this method to return localized text for the message. Android returns the regular detail message.
        Returns:
        this Throwable's localized detail message.
      • getStackTrace

        public StackTraceElement[] getStackTrace()
        Returns the array of stack trace elements of this Throwable. Each StackTraceElement represents an entry in the call stack. The element at position 0 is the top of the stack, that is, the stack frame where this Throwable is thrown.
        Returns:
        a copy of the array of StackTraceElements representing the call stack. Changes in the array obtained from this call will not change the call stack stored in this Throwable.
        See Also:
        printStackTrace()
      • setStackTrace

        public void setStackTrace(StackTraceElement[] trace)
        Sets the array of stack trace elements. Each StackTraceElement represents an entry in the call stack. A copy of the specified array is stored in this Throwable. will be returned by getStackTrace() and printed by printStackTrace().
        Parameters:
        trace - the new array of StackTraceElements. A copy of the array is stored in this Throwable, so subsequent changes to trace will not change the call stack stored in this Throwable.
        Throws:
        NullPointerException - if any element in trace is null.
        See Also:
        printStackTrace()
      • printStackTrace

        public void printStackTrace()
        Writes a printable representation of this Throwable's stack trace to the System.err stream.
      • printStackTrace

        public void printStackTrace(PrintStream err)
        Writes a printable representation of this Throwable's stack trace to the specified print stream. If the Throwable contains a cause, the method will be invoked recursively for the nested Throwable.
        Parameters:
        err - the stream to write the stack trace on.
      • printStackTrace

        public void printStackTrace(PrintWriter err)
        Writes a printable representation of this Throwable's stack trace to the specified print writer. If the Throwable contains a cause, the method will be invoked recursively for the nested Throwable.
        Parameters:
        err - the writer to write the stack trace on.
      • toString

        public String toString()
        Description copied from class: Object
        Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:
           getClass().getName() + '@' + Integer.toHexString(hashCode())

        See Writing a useful toString method if you intend implementing your own toString method.

        Overrides:
        toString in class Object
        Returns:
        a printable representation of this object.
      • initCause

        public Throwable initCause(Throwable throwable)
        Initializes the cause of this Throwable. The cause can only be initialized once.
        Parameters:
        throwable - the cause of this Throwable.
        Returns:
        this Throwable instance.
        Throws:
        IllegalArgumentException - if Throwable is this object.
        IllegalStateException - if the cause has already been initialized.
      • getCause

        public Throwable getCause()
        Returns the cause of this Throwable, or null if there is no cause.
        Returns:
        Throwable this Throwable's cause.
      • addSuppressed

        public final void addSuppressed(Throwable throwable)
        Adds throwable to the list of throwables suppressed by this. The throwable will included when this exception's stack trace is printed.
        Throws:
        IllegalArgumentException - if throwable == this.
        NullPointerException - if throwable == null.
        Since:
        1.7
      • getSuppressed

        public final Throwable[] getSuppressed()
        Returns the throwables suppressed by this.
        Since:
        1.7


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 176 / . Delta: 0.02656 с