error-handlers.red 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. %
  2. % ERROR-HANDLERS.RED - Low level error handlers
  3. %
  4. % Author: Eric Benson
  5. % Symbolic Computation Group
  6. % Computer Science Dept.
  7. % University of Utah
  8. % Date: 18 August 1981
  9. % Copyright (c) 1981 University of Utah
  10. %
  11. % <PERDUE.PSL>ERROR-HANDLERS.RED.2, 9-Dec-82 18:16:42, Edit by PERDUE
  12. % Changed continuable error message; also allows for no (NIL) retry form
  13. % <PSL.KERNEL>ERROR-HANDLERS.RED.2, 20-Sep-82 14:55:56, Edit by BENSON
  14. % Error number isn't printed
  15. % <PSL.INTERP>ERROR-HANDLERS.RED.11, 26-Feb-82 23:43:16, Edit by BENSON
  16. % Added BreakLevel!* check
  17. % <PSL.INTERP>ERROR-HANDLERS.RED.8, 28-Dec-81 17:02:43, Edit by BENSON
  18. % Compressed output in ContinuableError
  19. % MLG 7:18am Tuesday, 24 November 1981 - To print ErrorForm!* on ErrorOut!*
  20. fluid '(!*ContinuableError % if true, inside continuable error
  21. ErrorForm!*
  22. BreakLevel!* % nesting level of break loops
  23. MaxBreakLevel!* % maximum permitted ...
  24. !*EMsgP); % value of 2nd arg to previous errorset
  25. global '(EMsg!*); % gets message from most recent error
  26. on SysLisp;
  27. syslsp procedure FatalError S;
  28. << ErrorPrintF("***** Fatal error: %s", S);
  29. while T do Quit; >>;
  30. off SysLisp;
  31. lisp procedure RangeError(Object, Index, Fn);
  32. StdError BldMsg("Index %r out of range for %p in %p", Index, Object, Fn);
  33. lisp procedure StdError Message; %. Error without number
  34. Error(99, Message);
  35. SYMBOLIC PROCEDURE YESP U;
  36. BEGIN SCALAR BOOL,X,Y, OLDOUT, OLDIN, PROMPTSTRING!*;
  37. OLDIN := RDS NIL;
  38. OLDOUT := WRS ERROUT!*;
  39. % TERPRI();
  40. % PRIN2L U;
  41. % TERPRI();
  42. % TERPRI();
  43. if_system(Tops20, % ? in col 1, so batch jobs get killed
  44. PROMPTSTRING!* := BldMsg("?%l (Y or N) ", U),
  45. PROMPTSTRING!* := BldMsg("%l (Y or N) ", U));
  46. A: X := READ();
  47. IF (Y := (X MEMQ '(Y YES))) OR X MEMQ '(N NO) THEN GO TO B;
  48. % IF NULL BOOL THEN PRIN2T "TYPE Y OR N";
  49. if X = 'B then ErrorSet('(Break), NIL, NIL);
  50. if_system(Unix, % If read EOF, croak so shell scripts terminate
  51. if X eq !$EOF!$ then return (lambda(!*Break);
  52. StdError "End-of-file read in YesP")(NIL));
  53. BOOL := T;
  54. GO TO A;
  55. B: WRS OLDOUT;
  56. RDS OLDIN;
  57. CURSYM!* := '!*SEMICOL!*;
  58. RETURN Y
  59. END;
  60. lisp procedure ContinuableError(ErrNum, Message, ErrorForm!*); %. maybe fix
  61. begin scalar !*ContinuableError;
  62. !*ContinuableError := T;
  63. EMsg!* := Message;
  64. return if !*Break and !*EMsgP and BreakLevel!* < MaxBreakLevel!* then
  65. << ErrorPrintF("***** %l", Message); % Don't print number
  66. if null ErrorForm!* then
  67. ErrorPrintF("***** Continuable error.")
  68. else
  69. if FlatSize ErrorForm!* < 40 then
  70. ErrorPrintF("***** Continuable error: retry form is %r",
  71. ErrorForm!*)
  72. else
  73. << ErrorPrintF("***** Continuable error, retry form is:");
  74. ErrorPrintF("%p", ErrorForm!*) >>;
  75. Break() >>
  76. else Error(ErrNum, Message);
  77. end;
  78. END;