[http] Fix ‘err’ variable not being assigned in an except block (#2045)