// Not public, so we don't need a second file...
class YetAnotherException extends Exception {
    public YetAnotherException( String message ) {
        super(message);
    }
}

// Experiment: try removing the throws statements to see what happens,
// and try adding additional exception types.
public class AnotherExceptionDemo2 {
 
    public static int exampleMethod( int x ) throws YetAnotherException {
        if (x < 0)
            throw new YetAnotherException("THAT WHICH HAS GONE WRONG IS " + x);
        return 0;
    }

    public static void main(String args[]) {
        try {
            System.out.println("Something is about to go wrong; I can feel it!");
            System.out.println("First call: " + exampleMethod(1));
            System.out.println("Second call: " + exampleMethod(-1));
        }
        catch ( YetAnotherException y ) {
            System.out.println(y);
            System.out.println(y.getMessage());
            y.printStackTrace();
        }

        System.out.println("\nAnd I lived to tell the tale!");
    }
}

