javascript-catch.ecl 443 B

1234567891011121314151617181920
  1. IMPORT javascript;
  2. /*
  3. This example illustrates and tests the use of embedded JavaScript
  4. */
  5. // Mapping of exceptions from JavaScript to ECL
  6. integer testThrow(integer val) := EMBED(javascript) throw new Error("Error from JavaScript"); ENDEMBED;
  7. d := dataset([{ 1, '' }], { integer a, string m} ) : stored('nofold');
  8. d t := transform
  9. self.a := FAILCODE;
  10. self.m := FAILMESSAGE;
  11. self := [];
  12. end;
  13. catch(d(testThrow(a) = a), onfail(t));