Properly detect error