MathGroup Archive 1992

[Date Index] [Thread Index] [Author Index]

Search the Archive

Inequalities posting: Errors.m

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Inequalities posting: Errors.m
  • From: mstankus at oba.ucsd.edu (Mark Stankus)
  • Date: Fri, 20 Nov 92 11:24:38 PST

(* The following package allows an abort to be executed.
   An example of its usage would be
   
      foo defintitions here
           ...
      foo[x___] := BadCall["foo",x];

*)
(* :Title: 	Errors // Mathematica 1.2 and 2.0 *)

(* :Author: 	Mark Stankus (mstankus). *)

(* :Context: 	Errors` *)

(* :Summary:
*)

(* :Alias:
*)

(* :Warnings: 
*)

(* :History: 
*)
BeginPackage["Errors`"];

Clear[BadCall];

BadCall::usage = 
    "BadCall[string,rest] reports an error message \
     indicating that the routine with name \
     given by string was called incorrectly and rest \
     is the nonheaded list of parameters sent to that routine. \
     BadCall records the erroneous arguments. See \
     WhatAreBadArgs. BadCall then makes the aggresive move \
     of calling Abort[]!";

Clear[WhatAreBadArgs];

WhatAreBadArgs::usage = 
     "WhatAreBadArgs[] returns the error list of the \
      most recent call to BadCall. See BadCall.";

Begin["`Private`"];

BadCall[name_String,param___] := Block[{},
    Print["Severe error from :-( ",name];
    ErrorArgs = List[param];
    Print["The parameters are (as a list)",Short[ErrorArgs,3]];
    Print["Bad argument can be retrieved by a call to WhatAreBadArgs"];
    Print["\n\n Here is the stack:\n\n\n"];
    Print[Shallow[Stack[_],{2,4}]];
    Abort[];
];

BadCall[___] := Block[{},
      Print["If you see this message, send a message to ncalg and"];
      Print["tell us that we have a bad call error."];
      Abort[];
];
      
WhatAreBadArgs[] := ErrorArgs;

End[];
EndPackage[]





  • Prev by Date: Inequalities posting: Convert1.m
  • Next by Date: question
  • Previous by thread: Inequalities posting: Convert1.m
  • Next by thread: question