try.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. var e = 8;
  6. function x() { throw 7; }
  7. function y() {
  8. var i;
  9. for (i = 0; i < 10; i++) {
  10. try {
  11. if (i % 2 == 0) {
  12. try {
  13. x();
  14. }
  15. catch (e) {
  16. telemetryLog(`Inner catch: ${e}`, true);
  17. if (i % 3) {
  18. throw e;
  19. }
  20. if (i % 5) {
  21. return e;
  22. }
  23. }
  24. finally {
  25. telemetryLog(`Finally: ${i}`, true);
  26. continue;
  27. }
  28. }
  29. }
  30. catch (e) {
  31. telemetryLog(`Outer catch: ${e}`, true);
  32. }
  33. finally {
  34. telemetryLog(`Outer finally: ${i}`, true);
  35. if (++i % 9 == 0)
  36. return e;
  37. }
  38. }
  39. }
  40. WScript.SetTimeout(testFunction, 50);
  41. /////////////////
  42. function testFunction()
  43. {
  44. y();
  45. }