Skip to content

Instantly share code, notes, and snippets.

@shanerk
Last active December 13, 2018 15:08
Show Gist options
  • Save shanerk/6cdf17bd734eb421c8defbf836665e55 to your computer and use it in GitHub Desktop.
Save shanerk/6cdf17bd734eb421c8defbf836665e55 to your computer and use it in GitHub Desktop.
Apex Generic method to process Database.SaveResults
public with sharing class ApexDmlUtil {
public void processSaveResults(List<Database.SaveResult> results) {
List<String> errors;
for (Database.SaveResult r : results) {
if (!r.isSuccess()) {
RAL_MetricService.increment(RAL_MetricService.Metric.Errored, this.file.Id);
errors = new List<String>();
for (Database.Error e : r.errors) {
errors.add(e.message);
}
}
}
System.debug(LoggingLevel.ERROR, String.join(errors, '\n'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment