implemented correct error messages for login and registration. Added err...

...or_code for internal protocol errors to handle errors rather than just pass a message describing the error