Check error before handle return statement