diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2011-10-06 19:35:40 +0200 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2011-10-06 21:54:29 +0200 |
commit | 53494ccbd1a97d5de885c36151b02a66999c4847 (patch) | |
tree | 5a0490235c713d39a37d16875a635bbd16cd6ea2 /Tools/MathematicaMisc | |
parent | a50298e4d7caf1bbb78a7ee08de48da07443b1cd (diff) |
Errors.m: Add ErrorDefinition
This function can be used to create default definitions for functions which throw exceptions indicating unexpected arguments have been passed.
Diffstat (limited to 'Tools/MathematicaMisc')
-rw-r--r-- | Tools/MathematicaMisc/Errors.m | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Tools/MathematicaMisc/Errors.m b/Tools/MathematicaMisc/Errors.m index 4de9a65..2f0d6cd 100644 --- a/Tools/MathematicaMisc/Errors.m +++ b/Tools/MathematicaMisc/Errors.m @@ -9,6 +9,7 @@ VerifyStringList; VerifyList; InfoMessage; SetDebugLevel; +ErrorDefinition::usage = "ErrorDefinition[f] creates a default definition of a function f which throws an exception. This can be used to catch programming errors where f is called with incorrect arguments."; DebugQuiet = 0; Warnings = 1 @@ -88,6 +89,10 @@ InfoMessage[level_, message__] := SetDebugLevel[level_] := debugLevel = level; +ErrorDefinition[x_] := + x[args___] := + ThrowError["Invalid arguments to "<>ToString[x], {args}//FullForm]; + End[]; EndPackage[]; |