Fix set logic to check for error code on failure.