diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/amazon/carbonado/MismatchException.java | 36 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java | 4 |
2 files changed, 36 insertions, 4 deletions
diff --git a/src/main/java/com/amazon/carbonado/MismatchException.java b/src/main/java/com/amazon/carbonado/MismatchException.java index ddd64f6..f01c557 100644 --- a/src/main/java/com/amazon/carbonado/MismatchException.java +++ b/src/main/java/com/amazon/carbonado/MismatchException.java @@ -32,6 +32,7 @@ public class MismatchException extends SupportException { private static final long serialVersionUID = 5840495857407789424L;
+ private Class<?> mType;
private List<String> mMessages;
public MismatchException() {
@@ -49,11 +50,42 @@ public class MismatchException extends SupportException { mMessages = Collections.unmodifiableList(messages);
}
+ /**
+ * @since 1.2
+ */
+ public MismatchException(Class<?> malformedType) {
+ this();
+ mType = malformedType;
+ }
+
+ /**
+ * @since 1.2
+ */
+ public MismatchException(Class<?> malformedType, String message) {
+ this(message);
+ mType = malformedType;
+ }
+
+ /**
+ * @since 1.2
+ */
+ public MismatchException(Class<?> malformedType, List<String> messages) {
+ this(messages);
+ mType = malformedType;
+ }
+
+ @Override
public String getMessage() {
+ String message;
if (mMessages == null || mMessages.size() == 0) {
- return super.getMessage();
+ message = super.getMessage();
+ } else {
+ message = mMessages.get(0);
+ }
+ if (mType != null) {
+ message = mType.getName() + ": " + message;
}
- return mMessages.get(0);
+ return message;
}
/**
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java index 5ff713d..ee31b6c 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java @@ -383,7 +383,7 @@ public class JDBCStorableIntrospector extends StorableIntrospector { }
if (errorMessages.size() > 0) {
- throw new MismatchException(errorMessages);
+ throw new MismatchException(mainInfo.getStorableType(), errorMessages);
}
// Gather index info...
@@ -570,7 +570,7 @@ public class JDBCStorableIntrospector extends StorableIntrospector { }
if (errorMessages.size() > 0) {
- throw new MismatchException(errorMessages);
+ throw new MismatchException(mainInfo.getStorableType(), errorMessages);
}
return new JInfo<S>
|