detecting 401 and return error

for fixing #5