My Apex controller method might throw a custom exception
@AuraEnabled
public static Id myAction() {
// Provoke exception
Integer foo = 10 / 0;
and I want the toast to display it properly
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
title: 'Error',
type: 'error',
message: response.getError()[0]
});
toastEvent.fire();
Instead of my the string I passed into my custom exception I get this! What am I doing wrong?
Best Answer
Adding ugly wrapping code to all my
@AuraEnabled
methods seemed not to be an acceptable clean solution to me......so I solved it in my JS toast code.