summaryrefslogtreecommitdiff
path: root/Examples/javascript/exception/runme.js
blob: 43ce66d6dee55eceda83d3042fae7c5dfc7818af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var example = require("example");

console.log("Trying to catch some exceptions.");
t = new example.Test();
try{
  t.unknown();
  throw -1;
} catch(error)
{
  if(error == -1) {
    console.log("t.unknown() didn't throw");
  } else {
    console.log("successfully catched throw in Test::unknown().");
  }
}

try{
    t.simple();
    throw -1;
}
catch(error){
  if(error == -1) {
    console.log("t.simple() did not throw");
  } else {
    console.log("successfully catched throw in Test::simple().");
  }
}

try{
  t.message();
  throw -1;
} catch(error){
  if(error == -1) {
    console.log("t.message() did not throw");
  } else {
    console.log("successfully catched throw in Test::message().");
  }
}
    
try{
  t.hosed();
  throw -1;
}
catch(error){ 
  if(error == -1) {
    console.log("t.hosed() did not throw");
  } else {
    console.log("successfully catched throw in Test::hosed().");
  }
}

for (var i=1; i<4; i++) {
  try{
      t.multi(i);
      throw -1;
  }
  catch(error){
    if(error == -1) {
      console.log("t.multi(" + i + ") did not throw");
    } else {
      console.log("successfully catched throw in Test::multi().");
    }
  }
}