error-errorset.red 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. %
  2. % ERROR-ERRORSET.RED - The most basic ERROR and ERRORSET
  3. %
  4. % Author: Eric Benson
  5. % Symbolic Computation Group
  6. % Computer Science Dept.
  7. % University of Utah
  8. % Date: 20 August 1981
  9. % Copyright (c) 1981 University of Utah
  10. %
  11. % Edit by Cris Perdue, 4 Feb 1983 1208-PST
  12. % Moved ERRSET here from CATCH-THROW.RED.
  13. % Edit by Cris Perdue, 3 Feb 1983 1526-PST
  14. % Tidied up definition of ERRORSET.
  15. % <PSL.KERNEL>ERROR-ERRORSET.RED.3, 11-Oct-82 17:57:30, Edit by BENSON
  16. % Changed CATCH/THROW to new definition
  17. % <PSL.KERNEL>ERROR-ERRORSET.RED.2, 20-Sep-82 11:31:23, Edit by BENSON
  18. % Removed printing of error number in ERROR
  19. % <PSL.INTERP>ERROR-ERRORSET.RED.7, 26-Feb-82 23:44:01, Edit by BENSON
  20. % Added BreakLevel!* check
  21. % <PSL.INTERP>ERROR-ERRORSET.RED.5, 28-Dec-81 17:07:18, Edit by BENSON
  22. % Changed 3rd formal in ErrorSet to !*Inner!*Backtrace
  23. global '(EMsg!*); % gets current error message
  24. fluid '(!*BackTrace % controls backtrace printing (actual)
  25. !*Inner!*Backtrace % controls backtrace printing (formal)
  26. !*EMsgP % controls message printing
  27. !*Break % controls breaking
  28. BreakLevel!* % nesting level of breaks
  29. MaxBreakLevel!* % maximum permitted ...
  30. !*ContinuableError); % if T, inside a continuable error
  31. LoadTime
  32. << !*EmsgP := T;
  33. !*BackTrace := NIL;
  34. !*Break := T >>;
  35. lisp procedure Error(Number, Message); %. Throw to ErrorSet
  36. begin scalar !*ContinuableError;
  37. EMsg!* := Message;
  38. if !*EMsgP then
  39. << ErrorPrintF("***** %l", Message); % Error number is not printed
  40. if !*Break and BreakLevel!* < MaxBreakLevel!* then
  41. return Break() >>;
  42. return
  43. << if !*Inner!*BackTrace then BackTrace();
  44. Throw('!$Error!$, Number) >>;
  45. end;
  46. % More useful version of ERRORSET
  47. macro procedure errset u;
  48. (lambda(form, flag);
  49. list(list('lambda, '(!*Emsgp),
  50. list('catch, ''!$error!$, list('ncons, form))),
  51. flag))(cadr u, if null cddr u then t else caddr u);
  52. lisp procedure ErrorSet(Form, !*EMsgP, !*Inner!*BackTrace); %. Protected Eval
  53. Catch('!$Error!$, list(Eval Form)); % eval form
  54. END;