We should have a method to test the error.code because I thought this wasn't always a 401? Rather than a big if statement a method would be better so we can change/adapt more easily.