Check error before showing error message