Last active
December 13, 2018 15:08
-
-
Save shanerk/6cdf17bd734eb421c8defbf836665e55 to your computer and use it in GitHub Desktop.
Apex Generic method to process Database.SaveResults
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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