Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update exception message for Map converting failure #4803

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -128,6 +128,7 @@ public class MappingMongoConverter extends AbstractMongoConverter
implements ApplicationContextAware, EnvironmentCapable {

private static final String INCOMPATIBLE_TYPES = "Cannot convert %1$s of type %2$s into an instance of %3$s; Implement a custom Converter<%2$s, %3$s> and register it with the CustomConversions; Parent object was: %4$s";
private static final String INCOMPATIBLE_MAP = "Expected map like structure but found %s";
private static final String INVALID_TYPE_TO_READ = "Expected to read Document %s into type %s but didn't find a PersistentEntity for the latter";

public static final TypeInformation<Bson> BSON = TypeInformation.of(Bson.class);
Expand Down Expand Up @@ -2392,9 +2393,8 @@ public <S extends Object> S convert(Object source, TypeInformation<? extends S>
if (BsonUtils.supportsBson(source)) {
return (S) mapConverter.convert(context, BsonUtils.asBson(source), typeHint);
}

throw new IllegalArgumentException(
String.format("Expected map like structure but found %s", source.getClass()));
throw new MappingException(
String.format(INCOMPATIBLE_MAP, source));
}

if (source instanceof DBRef dbRef) {
Expand Down