Code reaches the error throwing part, showing a pop up alert(“player not found”); when expected.
Console also indicates that the error is thrown, but not caught: util.ts:598 Uncaught Error: PLAYER NOT FOUND
The catch block never happens. Is something wrong here?
Thanks for the help
try
{
firebase.database().ref().orderByChild('name').equalTo(path).limitToLast(1).on("value", function(snapshot)
{
if (!snapshot.val()) { alert("player not found"); throw new Error("PLAYER NOT FOUND"); }
snapshot.forEach(function(data)
{
datablob = data.val().name.slice(0,10) + "|" + data.val().score;
unityInstance.Module.SendMessage(objectName, callback, datablob);
});
});
}
catch(error)
{
alert("Error-caught BEGIN");
unityInstance.Module.SendMessage(objectName, fallback, "Error: " + error.message);
alert("Error-caught END");
}