public class ThrowableMessageExample{ public static void main(String[]args){ try{ int result = divide(10,0); } catch(throwable t){ String errorMessage = t.getMessage(); if(errorMessage!=null){ System.out.println("Caught on exception;"+errorMessage); } else{ System.out.println("Caught on exception with no specific message"); } } public static int divide(int c, int y) throws throwable{ if(y==0){ throwable error = new throwable("Divide by zero is not allowed"); throw error; } return x/y; } }