Error nesting structures "Try-catch", nay. The problem, as commented by @Ricardopunctual in the question is precisely needing more than a "Try-catch", not by syntax but by the structure of the code itself. Makes the same redundant, makes its readability difficult etc.
The goal of the structure is to capture exceptions (or errors) triggered by calls within the block try
. If I understand your use case correctly:
You can redeem your "users" and "posts" in the same "Try-catch" structure within it try
, if any of the rescues fires an exception or error will fall into the block catch
;
If necessary treat the errors separately, you can separate rescues into functions and these, in turn, have the "Try-catch" structures implemented in the way that best suits each one. So you can do your rescues and handle the bugs separately if you think it suits your case.
I hope I’ve helped in some way.
but why do you want to do this? Try/catch is to treat a code block, you can put too much code in Try, because you would need another?
– Ricardo Pontual