Writeconcern unacknowledged error hides other errors

I have a problem writing unit tests in Go for an application using mongodb. I want to use writeconcern journaled for ensuring data integrity on unit tests. So I set writeconcern on write operations to journaled. The application will have lots of change requests. So it is very important to ensure that mongodb queries are correct. But as I realize now, the mongodb-go-driver hides errors when setting the writeconcern on write-operations. No chance to get the real error except when I remove the writeconcern. I think the problem is in the following function of errors.go in the go-driver:

``
// processWriteError handles processing the result of a write operation. If the retrunResult matches
// the calling method’s type, it should return the result object in addition to the error.
// This function will wrap the errors from other packages and return them as errors from this package.
//
// WriteConcernError will be returned over WriteErrors if both are present.
func processWriteError(err error) (returnResult, error) {
switch {
case errors.Is(err, driver.ErrUnacknowledgedWrite):
return rrAll, ErrUnacknowledgedWrite
case err != nil:
switch tt := err.(type) {
case driver.WriteCommandError:
return rrMany, WriteException{
WriteConcernError: convertDriverWriteConcernError(tt.WriteConcernError),
WriteErrors: writeErrorsFromDriverWriteErrors(tt.WriteErrors),
Labels: tt.Labels,
Raw: bson.Raw(tt.Raw),
}
default:
return rrNone, replaceErrors(err)
}
default:
return rrAll, nil
}
}

I think it's not very practical that the writeconcern-error is returned over writeerrors. In my opinion other errors lead to writeconcern errors, so writeconcern errors are less important than other errors.

Please help

Sorry for the format. I cannot find a button for editing this post.

P.S. I’m using Go1.23.2 and the old mongo driver 1.17… I think with the new driver v2 this problem is solved as I realized now.