This doesn't address timing attacks, which are why this is done in the first place. If the code checks only for a username existing and returns the error message, this takes a measurably different amount of time compared to then also looking up if the password matches. The error shown isn't to dissuade people from using web pages to try to gain access to accounts - it's because the raw code itself doesn't know which…
SELECT "Id", "Hash", "Salt" FROM USERS WHERE "Email" = $input
if (results.length == 0) return -1; //No record, bad user, return early...
if (results["Hash"] != Hash(pwd.trim(), results["Salt"]) return -2; //invalid password