Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,25 @@
import com.mongodb.bulk.WriteConcernError;

/**
* The {@linkplain #getMessage() message} {@linkplain Formatter format} is {@code "v=1, code=%d,
* codeName=%s, message=%s, details=%s"}, where {@code details} is JSON produced with {@link
* org.bson.BsonDocument#toJson()}. We may change it in the future, in which case the version
* (marked with {@code v}) will be incremented.
* The {@linkplain #getMessage() message} {@linkplain Formatter format} is {@code "v=2, code=%d,
* codeName=%s, message=%s"}. We may change it in the future, in which case the version (marked with
* {@code v}) will be incremented.
*
* <p>The {@code details} field (BSON of the failing document, previously emitted in {@code v=1}) is
* intentionally omitted: it carried record-derived content into the DLQ and into DEBUG logs.
*/
public final class WriteConcernException extends NoStackTraceDlqException {
private static final long serialVersionUID = 1L;
private static final int MESSAGE_FORMAT_VERSION = 1;
private static final int MESSAGE_FORMAT_VERSION = 2;

public WriteConcernException(final WriteConcernError error) {
super(
String.format(
Locale.ENGLISH,
"v=%d, code=%d, codeName=%s, message=%s, details=%s",
"v=%d, code=%d, codeName=%s, message=%s",
MESSAGE_FORMAT_VERSION,
error.getCode(),
error.getCodeName(),
error.getMessage(),
error.getDetails().toJson()));
error.getMessage()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,24 @@
import com.mongodb.WriteError;

/**
* The {@linkplain #getMessage() message} {@linkplain Formatter format} is {@code "v=1, code=%d,
* message=%s, details=%s"}, where {@code details} is JSON produced with {@link
* org.bson.BsonDocument#toJson()}. We may change it in the future, in which case the version
* (marked with {@code v}) will be incremented.
* The {@linkplain #getMessage() message} {@linkplain Formatter format} is {@code "v=2, code=%d,
* message=%s"}. We may change it in the future, in which case the version (marked with {@code v})
* will be incremented.
*
* <p>The {@code details} field (BSON of the failing document, previously emitted in {@code v=1}) is
* intentionally omitted: it carried record-derived content into the DLQ and into DEBUG logs.
*/
public final class WriteException extends NoStackTraceDlqException {
private static final long serialVersionUID = 1L;
private static final int MESSAGE_FORMAT_VERSION = 1;
private static final int MESSAGE_FORMAT_VERSION = 2;

public WriteException(final WriteError error) {
super(
String.format(
Locale.ENGLISH,
"v=%d, code=%d, message=%s, details=%s",
"v=%d, code=%d, message=%s",
MESSAGE_FORMAT_VERSION,
error.getCode(),
error.getMessage(),
error.getDetails().toJson()));
error.getMessage()));
}
}