I have an Apex call which causes an error (ENTITY_IS_DELETED
, but it doesn’t matter which error it is). I might be able to fix that error, but now it somehow also returns successfully anyway, so the client is confused.
Both the server and the client seem off, as follows.
// MyClass
public static void apexCall()
{
// some code
// --> generates error
// return true; // -> Returns true anyways! This is the problem
}
In LWC, I call Apex. Now it catches the error, but then still proceeds to read the result anyway, which it shouldn’t! It should stop.
console.log( '1' );
apexCall( {
var1: myVar
} ).then((result) =>
{
console.log( '2 ' + result );
// ..
))
.catch((error) =>
{
log( 'x', this );
console.error( error );
});
The log goes unexpectedly from the error to logging the new result (true):
1
x
2 true