handle two type of error