From a3fb0a769c05f5a88a68c9762069cc0056207258 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Tue, 9 Oct 2018 19:51:29 +0200 Subject: Try/Catch support for native JS exceptions (#8955) * Try/Catch support for native JS exceptions * Better tests --- tests/js/tnativeexc.nim | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/js/tnativeexc.nim (limited to 'tests') diff --git a/tests/js/tnativeexc.nim b/tests/js/tnativeexc.nim new file mode 100644 index 000000000..ea371c1cd --- /dev/null +++ b/tests/js/tnativeexc.nim @@ -0,0 +1,31 @@ +discard """ + action: "run" +""" + +import jsffi + +# Can catch JS exceptions +try: + asm """throw new Error('a new error');""" +except JsError as e: + doAssert e.message == "a new error" +except: + doAssert false + +# Can distinguish different exceptions +try: + asm """JSON.parse(';;');""" +except JsEvalError: + doAssert false +except JsSyntaxError as se: + doAssert se.message == "Unexpected token ; in JSON at position 0" +except JsError as e: + doAssert false + +# Can catch parent exception +try: + asm """throw new SyntaxError();""" +except JsError as e: + discard +except: + doAssert false -- cgit 1.4.1-2-gfad0 summary refs log tree commit diff stats
path: root/tests/stdlib/tsortcall.nim
blob: 242e3fe4c5adb7349111e75c6872fc6f638a624c (plain) (blame)
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
65
66
67
68
69