# How to capture implicit fails in Plot or Show? [duplicate]

How can I make a construct similar to C++ functions:

try{} catch{}


I want to use it to avoid showing a lot of errors in the plot area when for example one of the arguments becomes complex or overflows etc. I want to avoid of creating a plot if ANYTHING goes wrong, so it does not look like the one below:

Show@Graphics[Line[{{Complex[1, 1]}, {Complex[2, 2]}}]]


Approaches like:

Check[Show[Graphics[Line[{{Complex[1, 1]}, {Complex[2, 2]}}]]], Show[Graphics[{}]]]


or

Check[Graphics[Line[{{Complex[1, 1]}, {Complex[2, 2]}}]], Show[Graphics[{}]]


also fail.

• Is Check useful? – cormullion Oct 16 '13 at 8:16
• I have tried, but it still plots that way, or maybe I am doing something wrong: Check[Show[Graphics[Line[{{Complex[1, 1]}, {Complex[2, 2]}}]]], Show[Graphics[{}]]] or Check[Graphics[Line[{{Complex[1, 1]}, {Complex[2, 2]}}]], Show[Graphics[{}]]] – Misery Oct 16 '13 at 8:20
• Check will only catch kernel messages. The pink boxes you see are formatting errors generated by the front end. Have a look at rcollyer's answer here for a way to check for these errors. – Simon Woods Oct 16 '13 at 8:34
• Try Catch[] :) – stathisk Oct 16 '13 at 8:46
• @Zet I fail to see how Catch would work here: clearly, the last examples of OP show that the problem is that no explicit error message is generated during evaluating the expression but the result is still wrong. So how to capture such an implicit failure? I have no idea, but it is a good question. – István Zachar Oct 16 '13 at 11:43