python-catch.ecl 467 B

1234567891011121314151617181920212223
  1. IMPORT Python;
  2. /*
  3. This example illustrates and tests the use of embedded Python
  4. */
  5. // Mapping of exceptions from Python to ECL
  6. integer testThrow(integer val) := EMBED(Python)
  7. raise Exception('Error from Python')
  8. ENDEMBED;
  9. // Can't catch an expression(only a dataset)
  10. d := dataset([{ 1, '' }], { integer a, string m} ) : stored('nofold');
  11. d t := transform
  12. self.a := FAILCODE;
  13. self.m := FAILMESSAGE;
  14. self := [];
  15. end;
  16. catch(d(testThrow(a) = a), onfail(t));