code: @Nullable
      public static String extractErrorMessage(final BsonDocument response) {
          if (response.isString("err")) {
              return response.getString("err").getValue();
          } else if (response.isString("errmsg")) {
              return response.getString("errmsg").getValue();
          } else {
              return null;
          }
      }
docs: For internal use only: extract the error message from the response to a write command.
  
  @param response the response
  @return the error message