Declare error outside of the if/else so we can use it in both conditions.