Skip to main content
2 of 2
Updated link
Doug B
  • 11.5k
  • 1
  • 37
  • 44

You cannot catch Limit exceptions.

The best you can do is use the Limits methods to test when you are approaching the limits and act accordingly (for example stop further processing and record an error).

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_limits.htm

For example

if (Limits.getLimitQueries() > 0) {
  //do your query
} else {
  //handle this error situation
}
Doug B
  • 11.5k
  • 1
  • 37
  • 44