blob: b74a152fe5b06c65c0321dd84aea9758a71b877a (
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
65
66
67
68
69
|
(.require
[library
[lux (.except if loop)
["$" documentation]
[data
[text (.only \n)
["%" \\format (.only format)]]]
[macro
["[0]" template]]]]
[\\library
["[0]" /]])
(.def .public documentation
(.List $.Module)
($.module /._
"Pure-Lux exception-handling functionality."
[($.default /.assertion)
($.documentation (/.Exception it)
"An exception provides a way to decorate error messages.")
($.documentation /.match?
"Is this exception the cause of the error message?"
[(match? exception error)])
($.documentation /.when
(format "If a particular exception is detected on a possibly-erroneous value, handle it."
\n "If no exception was detected, or a different one from the one being checked, then pass along the original value.")
[(when exception then try)])
($.documentation /.otherwise
"If no handler could be found to catch the exception, then run a function as a last-resort measure."
[(otherwise else try)])
($.documentation /.error
"Constructs an error message from an exception."
[(error exception message)])
($.documentation /.except
"Decorate an error message with an Exception and lift it into the error-handling context."
[(except exception message)])
($.documentation /.exception
(format "Define a new exception type."
\n "It mostly just serves as a way to tag error messages for later catching.")
["Simple case:"
(exception .public some_exception)]
["Complex case:"
(exception .public [arbitrary type variables] (some_exception [optional Text
arguments Int])
optional_body)])
($.documentation /.report
"An error report."
[(is Text
(report ["Row 0" value/0]
["Row 1" value/1]
,,,
["Row N" value/N]))])
($.documentation /.listing
(format "A numbered report of the entries on a list."
\n "NOTE: 0-based numbering.")
[(listing format entries)])
($.documentation /.with
"If a computation fails, prepends the exception to the error."
[(with exception message computation)])]
[]))
|