Servlet::Util::Exception - exception base class
eval {
Servlet::Util::Exception->throw("oops");
};
if ($@) {
warn "caught exception: $@\n";
}
This is a base class for exceptions. It extends
Exception::Class::Base. See Exception::Class for a full list of
inherited methods.
There is only one exception to the inherited API: tracing is on by
default. This means that a stack trace will be created when an
exception is thrown. By way of comparison to java.lang.Throwable,
it's as if fillInStackTrace()
is automatically called inside
throw()
. To selectively disable tracing for a subclass, do the
following:
My::Exception::do_trace(0);
new($msg)
-
Construct an instance with the given error message.
Exceptions are rarely directly constructed. Usually they are
constructed and thrown in one call to throw()
.
Parameters:
- $msg
-
the error message
throw($msg)
-
Constructs an instance with the given error essage and then
die()
s.
Parameters:
- $msg
-
the error message
getMessage()
-
Returns the error message.
toString()
-
Returns a short description of the exception, including the stack
trace if the exception has been thrown.
These commonly encountered exceptions are provided as utilities.
- Servlet::Util::IOException
-
Thrown to indicate than an I/O exception of some sort has occurred.
- Servlet::Util::IllegalArgumentException
-
Thrown to indicate that a method has been passed an illegal or
inappropriate argument.
- Servlet::Util::IllegalStateException
-
Thrown to indicate that a method has been invoked at an illegal or
inappropriate time.
- Servlet::Util::IndexOutOfBoundsException
-
Thrown to indicate that an index of some sort (such as to an array) is
out of range.
- Servlet::Util::UndefReferenceException
-
Thrown to indicate that undef was used in a case where a value is
required.
- Servlet::Util::UnsupportedEncodingException
-
Thrown to indicate that the chosen character encoding is unsupported
by the environment (most commonly encountered during character
conversions on byte streams).
the Exception::Class manpage
Brian Moseley, bcm@maz.org