File tree Expand file tree Collapse file tree 3 files changed +52
-1
lines changed
Expand file tree Collapse file tree 3 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -327,6 +327,51 @@ document {
327327 }
328328 }
329329
330+ doc ///
331+ Key
332+ Error
333+ Headline
334+ error information
335+ Description
336+ Text
337+ An instance of this class is a hash table containing the position and
338+ message of an error caught by @TO symbol attempt@.
339+ Example
340+ attempt 1 /0
341+ SeeAlso
342+ symbol attempt
343+ ///
344+
345+ doc ///
346+ Key
347+ symbol attempt
348+ Headline
349+ attempt to evaluate code and get information about any errors that occur
350+ Usage
351+ attempt c
352+ Description
353+ Text
354+ The code @VAR " c" @ is evaluated and a sequence containing two elements
355+ is returned. If the evaluation completes successfully, then the first
356+ element is the value and the second element is null .
357+ Example
358+ attempt 5
359+ Text
360+ If an error occurs, then the first element is null and the second element
361+ is an @TO Error@ object containing information about the error is
362+ returned.
363+ Example
364+ attempt 1 /0
365+ Text
366+ Note that this is a @TO Keyword @, not a method , and so it is not
367+ necessary to enclose @VAR " c" @ in parentheses.
368+ Example
369+ attempt 5 == " foo"
370+ {attempt error " bar" , 1 /2}
371+ attempt 1 /0; 1 /2
372+ SeeAlso
373+ symbol try
374+ ///
330375
331376document {
332377 Key => " recursionLimit" ,
Original file line number Diff line number Diff line change @@ -704,6 +704,8 @@ document {
704704 TO " error" ,
705705 TO " try" ,
706706 TO " throw" ,
707+ TO " attempt" ,
708+ TO " Error" ,
707709 }
708710 }
709711
@@ -733,7 +735,8 @@ document {
733735 " The behavior of interrupts (other than alarms) is unaffected." ,
734736 EXAMPLE " apply(-3..3,i->try 1/i else infinity)" ,
735737 Caveat => " We will change the behavior of this function soon so that it will be possible to catch errors of a particular type. Meanwhile, users are
736- recommended to use this function sparingly, if at all."
738+ recommended to use this function sparingly, if at all." ,
739+ SeeAlso => {" attempt" },
737740 }
738741
739742document {
Original file line number Diff line number Diff line change 1+ (val, err) = attempt error " foo"
2+ assert Equation (err#" message" , " foo" )
3+
14stderr << " --testing the error messages must be done manually" << endl
25end
36
You can’t perform that action at this time.
0 commit comments