fix error message not printed correctly