Calling the Service layer
The preceding examples have shown the use of the service class methods from Lightning Web Component Apex controller methods. Let’s take a closer look at what is happening here, the assumptions being made, and at other callers, an Apex Scheduler and a Lightning Web Component Apex controller. Throughout the rest of the book, you will also see other examples, such as Batch Apex and Platform Event Subscriptions.
Keep the following in mind when reviewing the following use cases:
- There is no need for the calling code shown in the following sections to concern itself with rolling back changes made within the service that may have been made to object records up to the exception being thrown since the caller is safe in the assumption that the
Service
method has already ensured this is the case. - Error handling in each of the following sections is unique, yet the way in which errors are received from the Service layer is consistent. To make...