My problem is very simple. Assume you have this piece of code :
FindRoot[{x^2 + 1 == 0}, {x, -1, 1}]
Now, this code returns
FindRoot::cvmit: Failed to converge to the requested accuracy or precision within 100 iterations. {x -> -1.}
Which is as expected since the equation has no real root. Now my question is, how can I get the fact that FindRoot failed in a variable ? Say I want to display a message "Failed search", when FindRoot fails for whatever reason, how do I collect the fact that the function failed ? I was looking into Catch[]
, but it seems that no exception is thrown.