You need to sign in to do that
Don't have an account?
Nicolas Astier
Apex error in lightning component
Hi,
I've hadded a lightning component's button to modify current opportunity via apex.
I'm printing the result of the operation and in case of an error, I would like to print the error's message.
I'm inducing an error "update failed" but I can't seem to get the error message in the window
This is the part of my code to handle errors so far:
results:
I've hadded a lightning component's button to modify current opportunity via apex.
I'm printing the result of the operation and in case of an error, I would like to print the error's message.
I'm inducing an error "update failed" but I can't seem to get the error message in the window
This is the part of my code to handle errors so far:
} else if (state === "ERROR") { var errors = response.getError(); if (errors) { if (errors[0] && errors[0].message) { component.set("v.messageError", errors[0].message); } else { component.set("v.messageError", errors.message); } } else { component.set("v.messageError", "unknown error"); } }
<aura:iteration items="{!v.errorMessages2}" var="message2"> <li class="minli"><h3> ResultMessage: {!v.messageError} </h3></li> </aura:iteration>apex:
catch(Exception e) { throw e; }
results:
If you want to throw any error from apex and show it in lightning , Please try below code :
Put it inside catch block
throw new AuraHandledException( ' Yor Error Message ==>'+e);
Hope it helps.
Cheers!!
Tanuj
All Answers
If you want to throw any error from apex and show it in lightning , Please try below code :
Put it inside catch block
throw new AuraHandledException( ' Yor Error Message ==>'+e);
Hope it helps.
Cheers!!
Tanuj