Hot answers tagged error-trapping
12
I have answered almost exactly this question (somewhat more general one, if we interpret this one as being concerned only with Throw and Catch) here. Since you asked a more narrow one, I feel it may be appropriate to borrow a part of my answer, to have it here.
The method
This method is IMO almost never appropriate for the top-level functions that are ...
10
The function Shuffle is not defined. If you define it (say, replace it with RandomSample) it works. Apparently, Rotate in the latter part of the code is being applied to the output of a function that uses edgeNoise which, in turn, (because Shuffle is undefined) is producing the error message you are seeing.
To replicate what is happening in a simple setting ...
8
A simple method for accomplishing this is to have Message Throw an error when it is called, interrupting the current execution. Here is a replacement for Check which does that, with the same calling signature:
ClearAll[InterruptingCheck]
SetAttributes[InterruptingCheck, HoldAll]
InterruptingCheck[expr_, failexpr_, msgs : {___MessageName } : {}] :=
...
5
I Trace-ed the Information[ f ] command both before and after an invocation of f (with a simpler definition f[x_] := Legended["123", x]). By comparing the results, I found a function System`Dump`makeusageboxes:
which reduces to another function BoxForm`MakeBoxesWithTextFormatting:
Attributes[BoxForm`MakeBoxesWithTextFormatting] = {HoldAllComplete}
...
5
What you look for is the function Check which will give you the possibility to implement what you ask for in several variants, the most simple probably be this:
success=Check[Import["test1.txt", "Table"];True, False]
See the documentation of Check for more details...
Only top voted, non community-wiki answers of a minimum length are eligible