home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / sci / math / symbolic / 3068 < prev    next >
Encoding:
Internet Message Format  |  1992-11-20  |  1.9 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!news.service.uci.edu!network.ucsd.edu!sdcc12!oba!mstankus
  2. From: mstankus@oba.ucsd.edu (Mark Stankus)
  3. Newsgroups: sci.math.symbolic
  4. Subject: Inequalities posting: Errors.m
  5. Message-ID: <41347@sdcc12.ucsd.edu>
  6. Date: 20 Nov 92 19:33:41 GMT
  7. References: <41345@sdcc12.ucsd.edu>
  8. Sender: news@sdcc12.ucsd.edu
  9. Organization: Mathematics @ UCSD
  10. Lines: 69
  11. Nntp-Posting-Host: oba.ucsd.edu
  12.  
  13. (* The following package allows an abort to be executed.
  14.    An example of its usage would be
  15.    
  16.       foo defintitions here
  17.            ...
  18.       foo[x___] := BadCall["foo",x];
  19.  
  20. *)
  21. (* :Title:     Errors // Mathematica 1.2 and 2.0 *)
  22.  
  23. (* :Author:     Mark Stankus (mstankus). *)
  24.  
  25. (* :Context:     Errors` *)
  26.  
  27. (* :Summary:
  28. *)
  29.  
  30. (* :Alias:
  31. *)
  32.  
  33. (* :Warnings: 
  34. *)
  35.  
  36. (* :History: 
  37. *)
  38. BeginPackage["Errors`"];
  39.  
  40. Clear[BadCall];
  41.  
  42. BadCall::usage = 
  43.     "BadCall[string,rest] reports an error message \
  44.      indicating that the routine with name \
  45.      given by string was called incorrectly and rest \
  46.      is the nonheaded list of parameters sent to that routine. \
  47.      BadCall records the erroneous arguments. See \
  48.      WhatAreBadArgs. BadCall then makes the aggresive move \
  49.      of calling Abort[]!";
  50.  
  51. Clear[WhatAreBadArgs];
  52.  
  53. WhatAreBadArgs::usage = 
  54.      "WhatAreBadArgs[] returns the error list of the \
  55.       most recent call to BadCall. See BadCall.";
  56.  
  57. Begin["`Private`"];
  58.  
  59. BadCall[name_String,param___] := Block[{},
  60.     Print["Severe error from :-( ",name];
  61.     ErrorArgs = List[param];
  62.     Print["The parameters are (as a list)",Short[ErrorArgs,3]];
  63.     Print["Bad argument can be retrieved by a call to WhatAreBadArgs"];
  64.     Print["\n\n Here is the stack:\n\n\n"];
  65.     Print[Shallow[Stack[_],{2,4}]];
  66.     Abort[];
  67. ];
  68.  
  69. BadCall[___] := Block[{},
  70.       Print["If you see this message, send a message to ncalg and"];
  71.       Print["tell us that we have a bad call error."];
  72.       Abort[];
  73. ];
  74.       
  75. WhatAreBadArgs[] := ErrorArgs;
  76.  
  77. End[];
  78. EndPackage[]
  79. -- 
  80. mstankus
  81. mstankus@oba 
  82.