How do I handle if the api error message is undefined?

If the login is successful, I do not receive an error message. My problem is that if no error message is received, the value of data.error.message is undefined and the program crashes. How can I solve this?

 if(data.error.message === 'EMAIL_NOT_FOUND'){
      setError({
        title: "EMAIL_NOT_FOUND",
        message: "This email address is not registered.",
      });
      setIsLoading(false);
      return;
    }
    if(data.error.message === 'EMAIL_NOT_FOUND' && data.error.message !== undefined){
      setError({
        title: "EMAIL_NOT_FOUND",
        message: "This email address is not registered.",
      });
      setIsLoading(false);
      return;
    }

I tried this too but same error.