Exempel

public class Example {
public void run() {
throw new Error( "Problem" ); //$NON-NLS-1$
}
}

Lösning
  1. Utöka java.lang.Exception.
  2. Ändra throws-satsdelen så att det nya undantaget används.

public static class ExceptionSubclass extends Exception {
public ExceptionSubclass( String s ){
super(s);
}
}

public class Example {
public void run() throws ExceptionSubclass {
throw new ExceptionSubclass( "Problem" ); //$NON-NLS-1$
}
}