You need to sign in to do that
Don't have an account?
Manoj Badam
custom exception in lightning component
I wanted to create a custom exception message and thought it to the lightning component .. Does its possible ?
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Visualforce pages have built-in implementation for showing custom error messages using the page as a medium. Here, we can easily show custom error screens with different text and levels of severity (info/error/warning) regardless of the return type of the apex controller method.
With Lightning components, we don’t have the flexibility to use page messages, and this makes the process more difficult. We have to return an error message for an apex controller method of which the return type is anything other than string (e.g., an apex method that returns a list of sObject).
To show custom error messages in Lightning:
Return the custom error messages from apex method.
Show the error messages in the Component.
Returning the custom error messages from apex method:
The recommended approach is to create — and throw — a System.AuraHandledException from your server-side controller to return a custom error message.
This can be done using the following syntax:
In the apex controller class: Showing the error messages in the Component.
To show the error message on the lightning component UI, we would use the following:
Generic reusable message component: Similar to a warning message, information and success screens could look like:
Hope this helps.
Kindly mark this as solved if the reply was helpful.
Thanks,
Nagendra
All Answers
Greetings to you!
Please refer to the below links which might help you further with the above requirement.
https://salesforce.stackexchange.com/questions/160160/show-custom-error-on-lightninginput
https://hub.appirio.com/tech-blog/custom-error-messages-in-salesforce-lightning
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_apex_custom_errors.htm
http://www.terrasky.com/how-to-handle-apex-errors-for-lightning-component-implementations/
https://webkul.com/blog/exception-handling-lightning-component/
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Visualforce pages have built-in implementation for showing custom error messages using the page as a medium. Here, we can easily show custom error screens with different text and levels of severity (info/error/warning) regardless of the return type of the apex controller method.
With Lightning components, we don’t have the flexibility to use page messages, and this makes the process more difficult. We have to return an error message for an apex controller method of which the return type is anything other than string (e.g., an apex method that returns a list of sObject).
To show custom error messages in Lightning:
Return the custom error messages from apex method.
Show the error messages in the Component.
Returning the custom error messages from apex method:
The recommended approach is to create — and throw — a System.AuraHandledException from your server-side controller to return a custom error message.
This can be done using the following syntax:
In the apex controller class: Showing the error messages in the Component.
To show the error message on the lightning component UI, we would use the following:
Generic reusable message component: Similar to a warning message, information and success screens could look like:
Hope this helps.
Kindly mark this as solved if the reply was helpful.
Thanks,
Nagendra