forked from mihaifm/linq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrorHandling.js
More file actions
executable file
·44 lines (41 loc) · 985 Bytes
/
errorHandling.js
File metadata and controls
executable file
·44 lines (41 loc) · 985 Bytes
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
var {test, testModule, deepEqual, equal} = require('./testutils.js')
var Enumerable = require('../linq.min');
testModule("ErrorHandling");
test("catchError", function ()
{
var msg;
let actual = Enumerable.range(1, 10)
.select(function (i)
{
if (i == 5) throw new Error("aiueo");
return i;
})
.catchError(function (e)
{
msg = e.message;
})
.toArray();
deepEqual(actual, [1, 2, 3, 4]);
equal(msg,"aiueo");
});
test("finallyAction", function ()
{
var msg;
let actual = Enumerable.range(1, 10)
.select(function (i)
{
if (i == 5) throw new Error("aiueo");
return i;
})
.catchError(function (e)
{
msg = e.message;
})
.finallyAction(function (f)
{
msg += "f";
})
.toArray();
deepEqual(actual, [1, 2, 3, 4]);
equal(msg, "aiueof");
});