Modify error handling during login (see #10011) (rebased onto develop)



This is the same as gh-883 but rebased onto develop.

----

Modify the error handling during the login attempt 
see https://trac.openmicroscopy.org.uk/ome/ticket/10011