Dear Salesforce StackExchange,
An outside partner set a precedent in some of our Apex triggers of doing major operations (such as DML) inside a try
/catch
block, and having the catch
block simply contain a System.Assert(false, 'Blah blah blah failed');
statement inside it.
I like this because something feels right about not propagating deep stack traces up to a user in production code. Like teaching your kids to say you're busy, rather than not home, when they answer the phone to a stranger.
That said, if I get an error with production data and want to see what lies below the 'Blah blah blah failed'
message, it's a royal pain to wait 20 minutes for validation tests to pass so I can replace the try-catch with a simple call to whatever was in the try
block (to allow deeper errors to bubble up to me).
Does anyone have any efficient, secure, portable suggestions to improve this kind of code so I can simply "flip a switch" in the org and let the code know, "Someone's looking deeply at errors - let them bubble up"?
Specifically ... where in the Salesforce org would you recommend I put the "switch?"
system.assert(false)
in production code.