+ Start a Discussion

System.LimitException: Apex CPU time limit exceeded



I am getting following exception


System.LimitException: Apex CPU time limit exceeded

Class.MailManager.IsTestPassed: line 142, column 1 Class.MailManager.SearchEmailTemplates: line 56, column 4 External entry point



I tried to handle same with try catch,


But there is no luck


Does anybody came across such exception ???


Any help on this will be great





Well that's kind of a chicken and egg problem.  I wouldn't think that you could possibly catch that exception because once you've hit it, you've expired all your available CPU time -- it won't give you another millisecond!


So what is it you're doing that's hogging all the CPU?  That's what I'd be looking at.  Perhaps there's something you can make more efficient.


Thanks for reply,


I had queried all email templates, while iterating through them,

Time limit get finished. :(


Now I am looking for processing Email template with small chunks