To make Lightning Component controller server-side calls to Apex, use the @AuraEnabled annotation method and the applicable Lightning Aura Component or Lightning Web Component communication method (as outlined in the earlier table) to invoke the method:
public with sharing class RaceResultsController { @AuraEnabled public static List<RaceService.ProvisionalResult>
loadProvisionalResults(Id raceId) {
try { return RaceService.calculateProvisionResults( new Set<Id>{ raceId }).get(raceId);
} catch (Exception e) {
Application.throwAuraHandledException(e);
} }
You will need to ensure that you throw an AuraHandledException exception from your controller code to allow the platform to pass the error to your client code. As previously discussed, we are using a utility function...