Fix local variable 'reason_err' referenced before assignment #1985