try {
// code
} catch (AcmeException e) {
}
try {
// code
try {
// code
} catch (...) {
// code
}
} catch (...) {
// code
}
try {
// code
} catch (...) {
try {
// code
} catch (...) {
// code
}
}
// code
try {
// code
} catch (...) {
// code
}
// code
try {
// code
} catch (...) {
// code
}
String foo() {
String s = "";
try {
// code
s = ...;
// code
} catch(ABCException e) {
// handling of Error(?)
}
return s;
}
public String getFoo(...) {
try {
// code
return ...;
} catch (ABCException e) {
// error-handling
return "";
}
}
public get(Foo foo, Bar bar) {
Baz baz = foo.get(bar);
return get(baz);
}
private get(Baz baz) {
try {
// code
return ...;
} catch (ABCException e) {
LOGGER.warn(baz);
return ...;
}
}
try {
// code
} catch (Exception e) {
// DON'T
}
try {
// code
foo.throwsABCException();
// code
} catch (ABCException e) {
// code
}
try {
// code
foo.throwsBazException();
// code
} catch (ABCException e) {
// Compiler Error!!
}
try {
// code
} catch(ABCException | FooException e) {
// code
}
public class InsufficientFundsException
extends Exception {
private double amount;
public InsufficientFundsException(double amount) {
this.amount;
}
public double getAmount() {
return this.amount;
}
}
try {
// code
} catch (ServiceException e) {
throw new InsufficientFundsException(amount);
}
try {
// code
} catch(RepositoryException e) {
throw new AssertionError(e);
}