Package org.apache.commons.lang
Class NotImplementedException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
java.lang.UnsupportedOperationException
org.apache.commons.lang.NotImplementedException
- All Implemented Interfaces:
Serializable,Nestable
Thrown to indicate that a block of code has not been implemented.
This exception supplements UnsupportedOperationException
by providing a more semantically rich description of the problem.
NotImplementedException represents the case where the
author has yet to implement the logic at this point in the program.
This can act as an exception based TODO tag.
Because this logic might be within a catch block, this exception
suports exception chaining.
public void foo() {
try {
// do something that throws an Exception
} catch (Exception ex) {
// don't know what to do here yet
throw new NotImplementedException("TODO", ex);
}
}
- Since:
- 2.0
- Version:
- $Id: NotImplementedException.java 905636 2010-02-02 14:03:32Z niallp $
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newNotImplementedExceptionwith default message.NotImplementedException(Class clazz) Constructs a newNotImplementedExceptionreferencing the specified class.Constructs a newNotImplementedExceptionwith specified detail message.NotImplementedException(String msg, Throwable cause) Constructs a newNotImplementedExceptionwith specified detail message and nestedThrowable.NotImplementedException(Throwable cause) Constructs a newNotImplementedExceptionwith specified nestedThrowableand default message. -
Method Summary
Modifier and TypeMethodDescriptiongetCause()Gets the root cause of this exception.Gets the combined the error message of this and any nested errors.getMessage(int index) Returns the error message of theThrowablein the chain ofThrowables at the specified index, numbered from 0.String[]Returns the error message of this and any nestedThrowableobjects.getThrowable(int index) Returns theThrowablein the chain by index.intReturns the number of nestedThrowables represented by thisNestable, including thisNestable.Returns thisNestableand any nestedThrowables in an array ofThrowables, one element for eachThrowable.intindexOfThrowable(Class type) Returns the index of the first occurrence of the specified type.intindexOfThrowable(Class type, int fromIndex) Returns the index of the first occurrence of the specified type starting from the specified index.final voidPrints the stack trace for this exception only (root cause not included) using the specified writer.voidPrints the stack trace of this exception.voidPrints the stack trace of this exception to the specified stream.voidPrints the stack trace of this exception to the specified writer.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getLocalizedMessage, getStackTrace, getSuppressed, initCause, setStackTrace, toString
-
Constructor Details
-
NotImplementedException
public NotImplementedException()Constructs a newNotImplementedExceptionwith default message.- Since:
- 2.1
-
NotImplementedException
Constructs a newNotImplementedExceptionwith specified detail message.- Parameters:
msg- the error message.
-
NotImplementedException
Constructs a newNotImplementedExceptionwith specified nestedThrowableand default message.- Parameters:
cause- the exception that caused this exception to be thrown- Since:
- 2.1
-
NotImplementedException
Constructs a newNotImplementedExceptionwith specified detail message and nestedThrowable.- Parameters:
msg- the error messagecause- the exception that caused this exception to be thrown- Since:
- 2.1
-
NotImplementedException
Constructs a newNotImplementedExceptionreferencing the specified class.- Parameters:
clazz- theClassthat has not implemented the method
-
-
Method Details
-
getCause
Gets the root cause of this exception. -
getMessage
Gets the combined the error message of this and any nested errors.- Specified by:
getMessagein interfaceNestable- Overrides:
getMessagein classThrowable- Returns:
- the error message
- Since:
- 2.1
-
getMessage
Returns the error message of theThrowablein the chain ofThrowables at the specified index, numbered from 0.- Specified by:
getMessagein interfaceNestable- Parameters:
index- the index of theThrowablein the chain- Returns:
- the error message, or null if the
Throwableat the specified index in the chain does not contain a message - Throws:
IndexOutOfBoundsException- if theindexargument is negative or not less than the count ofThrowables in the chain- Since:
- 2.1
-
getMessages
Returns the error message of this and any nestedThrowableobjects. Each throwable returns a message, a null string is included in the array if there is no message for a particularThrowable.- Specified by:
getMessagesin interfaceNestable- Returns:
- the error messages
- Since:
- 2.1
-
getThrowable
Returns theThrowablein the chain by index.- Specified by:
getThrowablein interfaceNestable- Parameters:
index- the index to retrieve- Returns:
- the
Throwable - Throws:
IndexOutOfBoundsException- if theindexargument is negative or not less than the count ofThrowables in the chain- Since:
- 2.1
-
getThrowableCount
public int getThrowableCount()Returns the number of nestedThrowables represented by thisNestable, including thisNestable.- Specified by:
getThrowableCountin interfaceNestable- Returns:
- the throwable count
- Since:
- 2.1
-
getThrowables
Returns thisNestableand any nestedThrowables in an array ofThrowables, one element for eachThrowable.- Specified by:
getThrowablesin interfaceNestable- Returns:
- the
Throwables - Since:
- 2.1
-
indexOfThrowable
Returns the index of the first occurrence of the specified type. If there is no match,-1is returned.- Specified by:
indexOfThrowablein interfaceNestable- Parameters:
type- the type to search for- Returns:
- index of the first occurrence of the type in the chain, or -1 if the type is not found
- Since:
- 2.1
-
indexOfThrowable
Returns the index of the first occurrence of the specified type starting from the specified index. If there is no match,-1is returned.- Specified by:
indexOfThrowablein interfaceNestable- Parameters:
type- the type to search forfromIndex- the index of the starting position in the chain to be searched- Returns:
- index of the first occurrence of the type in the chain, or -1 if the type is not found
- Throws:
IndexOutOfBoundsException- if thefromIndexargument is negative or not less than the count ofThrowables in the chain- Since:
- 2.1
-
printStackTrace
public void printStackTrace()Prints the stack trace of this exception. Includes information from the exception, if any, which caused this exception.- Overrides:
printStackTracein classThrowable- Since:
- 2.1
-
printStackTrace
Prints the stack trace of this exception to the specified stream. Includes information from the exception, if any, which caused this exception.- Specified by:
printStackTracein interfaceNestable- Overrides:
printStackTracein classThrowable- Parameters:
out- the stream to write to- Since:
- 2.1
-
printStackTrace
Prints the stack trace of this exception to the specified writer. Includes information from the exception, if any, which caused this exception.- Specified by:
printStackTracein interfaceNestable- Overrides:
printStackTracein classThrowable- Parameters:
out- the writer to write to- Since:
- 2.1
-
printPartialStackTrace
Prints the stack trace for this exception only (root cause not included) using the specified writer.- Specified by:
printPartialStackTracein interfaceNestable- Parameters:
out- the writer to write to- Since:
- 2.1
-