Fix error handling inconsistency