Skip to main content
How to write the exception, if the employee id and EmpName is there or not. If the Emp id is not there then throw the user-friendly message which one is understand by Enduser.(using Slaesforce using custom controller class).And that EmpID is a standard field(Auto generated).
2 answers
  1. May 30, 2022, 1:49 PM
    HI Rasmita,

    The question is quite broad. You might want to add what you have tried so far and where exactly you are stuck. If you are trying to Create Custom Exceptions, see the example code on https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_exception_custom.htm to get started.

    About

    Returning Errors from an Apex Server-Side Controller: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_apex_custom_errors.htm

    Related: https://salesforce.stackexchange.com/questions/179127/try-catch-blocks-within-a-custom-controller

    If this information helps, please mark the answer as best. Thank you
0/9000