Some programming languages have exception handling structures, namely try-catch
blocks. One that I know to give an example it Matlab. Consider the following pseudocode masterpiece:
try
command_that_will_throw_error
catch the_error
disp('The command_that_will_throw_error has finished unexpectedly! D=')
end
disp('But the show can never stop!')
The program tries to execute the command_that_will_throw_error
, fails, stores information about the error in the_error
, and then passes the execution to the catch
part of the block, so the result of the code above will be:
The command_that_will_throw(error) has finished unexpectedly! D=
But the show can never stop!
My curiosity induced question is: can (La)TeX do something like this?
My guess is that the answer is no, but the last time I said this, @egreg proved me wrong, so...
Before someone asks, what I'm trying to do is to programatically include some pdf files in my document, some of which may not exist. I would like to make TeX just skip them or print something if said pdf file does not exist.
I accept an answer to my actual problem with the pdf files, but I would to know about the error handling issue for general cases.
shell-escape
, I guess :) But I doubt it is worth-it or robust...