/usr/share/axiom-20170501/src/algebra/ERROR.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | )abbrev package ERROR ErrorFunctions
++ Author: Robert S. Sutor
++ Date Created: 29 May 1990
++ Date Last Updated: 29 May 1990
++ Description:
++ ErrorFunctions implements error functions callable from the system
++ interpreter. Typically, these functions would be called in user
++ functions. The simple forms of the functions take one argument
++ which is either a string (an error message) or a list of strings
++ which all together make up a message. The list can contain
++ formatting codes (see below). The more sophisticated versions takes
++ two arguments where the first argument is the name of the function
++ from which the error was invoked and the second argument is either a
++ string or a list of strings, as above. When you use the one
++ argument version in an interpreter function, the system will
++ automatically insert the name of the function as the new first
++ argument. Thus in the user interpreter function\br
++ \tab{5}\spad{f x == if x < 0 then error "negative argument" else x}\br
++ the call to error will actually be of the form\br
++ \tab{5}\spad{error("f","negative argument")}\br
++ because the interpreter will have created a new first argument.
++
++ Formatting codes: error messages may contain the following
++ formatting codes (they should either start or end a string or
++ else have blanks around them):\br
++ \spad{%l}\tab{6}start a new line\br
++ \spad{%ceon}\tab{3}start centering message lines\br
++ \spad{%ceoff}\tab{2}stop centering message lines\br
++ \spad{%rjon}\tab{3}start displaying lines "ragged left"\br
++ \spad{%rjoff}\tab{2}stop displaying lines "ragged left"\br
++ \spad{%i}\tab{6}indent following lines 3 additional spaces\br
++ \spad{%u}\tab{6}unindent following lines 3 additional spaces\br
++ \spad{%xN}\tab{5}insert N blanks (eg, \spad{%x10} inserts 10 blanks)
++
++ Examples:\br
++ 1.\spad{error "Whoops, you made a %l %ceon big %ceoff %l mistake!"}\br
++ 2.\spad{error ["Whoops, you made a","%l %ceon ","big",\br
++ \tab{10}"%d %ceoff %l","mistake!"]}
ErrorFunctions() : SIG == CODE where
SIG ==> with
error : String -> Exit
++ error(msg) displays error message msg and terminates.
error : List String -> Exit
++ error(lmsg) displays error message lmsg and terminates.
error : (String,String) -> Exit
++ error(nam,msg) displays error message msg preceded by a
++ message containing the name nam of the function in which
++ the error is contained.
error : (String,List String) -> Exit
++ error(nam,lmsg) displays error messages lmsg preceded by a
++ message containing the name nam of the function in which
++ the error is contained.
CODE ==> add
prefix1 : String := "Error signalled from user code: %l "
prefix2 : String := "Error signalled from user code in function "
doit(s : String) : Exit ==
throwKeyedMsg(s,nil$(List String))$Lisp
-- there are no objects of type Exit, so we'll fake one,
-- knowing we will never get to this step anyway.
"exit" pretend Exit
error(s : String) : Exit ==
doit concat [prefix1,s]
error(l : List String) : Exit ==
s : String := prefix1
for x in l repeat s := concat [s," ",x]
doit s
error(fn : String,s : String) : Exit ==
doit concat [prefix2,fn,": %l ",s]
error(fn : String, l : List String) : Exit ==
s : String := concat [prefix2,fn,": %l"]
for x in l repeat s := concat [s," ",x]
doit s
|