[SalesForce] How to handle system limit exception

I am getting this limit exception : System.LimitException:Too many callouts: 11

when I make a callout as this exception can not be catch, can someone help me how to handle this exception on visualforce page

any help will be appreciated.. Thanks

Best Answer

You cannot catch limit exceptions. Instead you need to prevent causing one. You can use the Limits class methods to find out how many callouts you have remaining.

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_limits.htm

Call Limits.getLimitCallouts() and check that this is greater than 0 before making a callout.

As Sdry has said, it sounds like you may need to refactor your design

Related Topic