/usr/share/yacas/io.rep/errors.ys is in yacas 1.3.3-2.
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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | //////////////////////////////////////////////////
/// ErrorTableau, Assert, IsError --- global error reporting
//////////////////////////////////////////////////
LocalSymbols(ErrorTableau) [
/// global error tableau. Its entries do not have to be lists.
Set(ErrorTableau, {});
GetErrorTableau() := ErrorTableau;
ClearErrors() <-- Set(ErrorTableau, {});
/// aux function to check for corrupt tableau
CheckErrorTableau() <--
If(
Not IsList(ErrorTableau),
Set(ErrorTableau, {{"general", "corrupted ErrorTableau"}})
);
]; // LocalSymbols(ErrorTableau)
/// check for errors
IsError() <--
[
CheckErrorTableau();
Length(GetErrorTableau())>0;
];
/// check for errors of a given kind
IsError(error'class_IsString) <--
[
CheckErrorTableau();
GetErrorTableau()[error'class] != Empty;
];
/// post an error if assertion fails
(Assert(_error'class, _error'object) _predicate) <--
[
CheckErrorTableau();
If(Equals(predicate, True), // if it does not evaluate to True, it's an error
True,
[ // error occurred, need to post error'object
DestructiveAppend(GetErrorTableau(), {error'class, error'object});
False;
]
);
];
/// interface
(Assert(_error'class) _predicate) <-- Assert(error'class, True) predicate;
/// interface
(Assert() _predicate) <-- Assert("generic", True) predicate;
/// print all errors and clear the tableau
DumpErrors() <--
[
Local(error'object, error'word);
CheckErrorTableau();
ForEach(error'object, GetErrorTableau())
[ // error'object might be e.g. {"critical", {"bad bad", -1000}}
If(
IsList(error'object),
[
If( // special case: error class "warning"
Length(error'object) > 0 And error'object[1] = "warning",
[
error'word := "Warning";
error'object[1] := ""; // don't print the word "warning" again
],
error'word := "Error: " // important hack: insert ": " here but not after "Warning"
);
If( // special case: {"error'class", True}
Length(error'object)=2 And error'object[2]=True,
Echo(error'word, error'object[1]),
[
Echo(error'word, error'object[1], ": ",
PrintList(Tail(error'object)));
]
);
],
// error'object is not a list: just print it
Echo("Error: ", error'object)
);
];
ClearErrors();
];
/// obtain error object
GetError(error'class_IsString) <--
[
Local(error);
error := GetErrorTableau()[error'class];
If(
error != Empty,
error,
False
);
];
/// delete error
ClearError(error'class_IsString) <-- AssocDelete(GetErrorTableau(), error'class);
//////////////////////////////////////////////////
|