Contents
How to display an error message from Apex code?
You can display error messages using the addError method on sobject or its fields. Salesforce docs on the sobject instance addError method: https://developer.salesforce.com/docs/atlas.en-us.198.0.apexcode.meta/apexcode/apex_methods_system_sobject.htm#apex_System_SObject_addError
What happens when an exception is thrown in apex?
These errors take the form of an Exception being thrown in the Apex code. If you process a failing server request as is (see code below), a system exception is returned to the Lightning component.
How are errors handled in lightning and apex?
The controller sends a response to the Lightning component. The Lightning component processes the response in a callback function. This can trigger a client-side error (unexpected response). If we omit the network-related errors, this pattern can trigger two types of errors that developers must handle: server-side and client-side errors.
How are client side errors similar to apex exceptions?
Client-side errors take the form of a JavaScript Error being thrown. An Error is very similar to Apex Exception: It’s a type built with a constructor, and it supports the same throw-catch syntax. ? Just like Apex Exceptions, JavaScript Errors enable you to separate result values from errors when you call a function.
Is there a limit to how many soql queries apex can handle?
You also can’t expose logic to be re-used anywhere else in your org. Bulkifying Apex code refers to the concept of making sure the code properly handles more than one record at a time. An individual Apex request gets a maximum of 100 SOQL queries before exceeding that governor limit.
Do you need multiple apex triggers for one object?
A single Apex Trigger is all you need for one particular object. If you develop multiple Triggers for a single object, you have no way of controlling the order of execution if those Triggers can run in the same contexts If you write methods in your Triggers, those can’t be exposed for test purposes.