A helper class will throw a custom exception and which has complex logic. I need to catch this exception when invoking it, so I call this helper class in the try block.
I want to ask, is that OK if I put a lot of code in the try block?
It's ok, but you'll have less granular error handling. i.e. say you want to insert an account, and whether that fails or not you want to insert a contact, having them both in the same block would not allow that:
By using separate blocks you can try the contact regardless of whether the account worked:
At the end of the day it depends on what level of error handling you want to do, generally with a transaction-style interface like VF controllers etc. I find that most things are all or nothing and do find myself using larger blocks.
Similar to @LaceySnr (for whom I have great respect), my variation on this where the catch action is always the same is the following (assuming a VF controller):
where [XX-nn] is from some programmer-managed list of error codes to assist tracing back a reported error to the code section. The