Try.k 369 B

12345678910111213141516171819
  1. invoke {
  2. function raise_error () -> Void {
  3. throw custom_error('oops')
  4. }
  5. function test () -> String {
  6. try to do_sth {
  7. raise_error()
  8. }
  9. return 'impossible'
  10. ...
  11. handle error {
  12. failed to do_sth {
  13. return 'caught'
  14. }
  15. }
  16. }
  17. assert test() == 'caught'
  18. }