class PengaturanRusakException extends RuntimeException {
    PengaturanRusakException(String pesan, Throwable cause) {
        super(pesan, cause);
    }
}

public class RantaiPenyebab {
    static int bacaAngka(String teks) {
        return Integer.parseInt(teks);
    }

    static int muatPengaturan(String nama, String nilai) {
        try {
            return bacaAngka(nilai);
        } catch (NumberFormatException e) {
            throw new PengaturanRusakException(
                    "pengaturan '" + nama + "' tidak berupa angka", e);
        }
    }

    public static void main(String[] args) {
        try {
            System.out.println("umur: " + muatPengaturan("umur", "abc"));
        } catch (PengaturanRusakException e) {
            System.out.println("rantai kegagalan:");
            Throwable t = e;
            while (t != null) {
                System.out.println("- " + t.getClass().getSimpleName() + ": " + t.getMessage());
                t = t.getCause();
            }
        }
    }
}
