Correctly handle error cases.