I have this newbie question: in Standard ML, how can you catch an exception like “Error: unbound variable or constructor: foo”?
I tried to do this with the following program:
(foo())
handle Error msg => ();
But REPL complains: “Error: non-constructor applied to argument in pattern: Error”
Thanks in advance.
First of all it’s
handle Error => ...(orhandle error => ...orhandle TheSpecificExceptionIWantToCatch => ...), nothandle Error msg => .... You can only writehandle Foo msg => ...ifFoois a constructor with one argument, which, as the error message suggests,Erroris not.Secondly “unbound variable” is a compilation error, not an exception, so it can’t be caught.