-- Demonstrates: -- declaring exceptions -- declaring exceptions with messages -- ada.exceptions.exception_name -- ada.exceptions.exception_message with ada.text_io; use ada.text_io; with ada.integer_text_io; use ada.integer_text_io; with ada.exceptions; use ada.exceptions; procedure excep3 is Invalid_Data: Exception; n: integer; begin loop put("Enter an even number less than 1000, negative to quit:"); get(n); if n >= 1_000 then raise Invalid_Data; elsif n mod 2 = 1 then raise Invalid_Data with "Number must be even!"; end if; exit when n < 0; put_line(n'img); end loop; exception when e: Invalid_Data => put(exception_name(e)); put(". Data was not valid! "); put(exception_message(e)); when e: Others => put("Something unexpected happened! "); put(exception_name(e)); put(exception_message(e)); end excep3;