connection: add error handling to credentials.