|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.lang.Throwable
java.lang.Exception
com.opensymphony.util.MultipartException
Exception to encapsulate many exceptions.
class MyException extends MultipartException {
// No class body needed as overrides default constructor.
}
public void doStuff() {
try {
checkEverything();
println("Everything went fine.");
}
catch (MultipartException error) {
Iterator i = error.list();
println("Failed:");
while(i.hasNext()) {
println(" - " + (String)i.next() );
}
}
}
private void checkEverything() throws MyException {
MyException m = new MyException;
// add some exceptions if methods don't check out.
if ( !verifySomething() ) m.add("Something not verified");
if ( !verifySomethingElse() ) m.add("Something else not verified");
// also (just for fun), add an exception if another exception is called.
try {
someMethodThatThrowsAnException()
}
catch(SomeWeirdException e) {
m.add(e)
}
// check if any exceptions have been added and re-throw in one go if they have.
if (m.hasErrors()) throw m;
}
Exception,
List,
Serialized Form| Field Summary | |
protected List |
errors
List used internally to store Strings of error messages. |
| Constructor Summary | |
MultipartException()
Default constructor. |
|
| Method Summary | |
void |
add(String msg)
Add an error message to the Exception. |
void |
add(Throwable exception)
Add an Exception's error message to the Exception. |
String[] |
getArray()
Return error msgs as String array. |
Iterator |
getIterator()
Return Iterator of String error msgs. |
List |
getList()
Return error msgs as List of Strings. |
boolean |
hasErrors()
Check whether any errors have been added. |
Iterator |
list()
Deprecated. Use getIterator() instead. |
| Methods inherited from class java.lang.Throwable |
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected List errors
| Constructor Detail |
public MultipartException()
| Method Detail |
public String[] getArray()
public Iterator getIterator()
public List getList()
public void add(String msg)
msg - Error message.public void add(Throwable exception)
exception - Exception of which getMessage() is called to add the message.public boolean hasErrors()
public Iterator list()
String representations of error message.
|
OSCore Project Page | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||