diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2011-10-07 18:17:20 +0200 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2011-10-07 18:17:20 +0200 |
commit | bfe6bb69eb19a5d8eea78f3877a373e322f1bfbf (patch) | |
tree | c30fe94c3f572b6c577120d8681abaaf374ecc74 /Tools/MathematicaMisc/Errors.m | |
parent | 4c20e5c17b6c343bd8d8c4285591d2c67afad0bf (diff) |
Errors.m: Add DefFn function for defining functions
This means that ErrorDefinition can be applied automatically. In future we could add profiling and stack information for backtraces.
Diffstat (limited to 'Tools/MathematicaMisc/Errors.m')
-rw-r--r-- | Tools/MathematicaMisc/Errors.m | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Tools/MathematicaMisc/Errors.m b/Tools/MathematicaMisc/Errors.m index 2f0d6cd..34c19b0 100644 --- a/Tools/MathematicaMisc/Errors.m +++ b/Tools/MathematicaMisc/Errors.m @@ -16,6 +16,7 @@ Warnings = 1 Terse = 2; Info = 3; InfoFull = 4; +DefFn; Begin["`Private`"]; @@ -93,6 +94,14 @@ ErrorDefinition[x_] := x[args___] := ThrowError["Invalid arguments to "<>ToString[x], {args}//FullForm]; +SetAttributes[DefFn, HoldAll]; + +DefFn[def:(fn_[args___] := body_)] := + Module[ + {}, + ErrorDefinition[fn]; + def]; + End[]; EndPackage[]; |