Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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