summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2007-06-07 15:32:29 +0000
committerBrian S. O'Neill <bronee@gmail.com>2007-06-07 15:32:29 +0000
commite69fc3804d93419b8f44035bb8d7a35bf052246a (patch)
tree0b64b38532a380fd2106f859a82d29934303a1b8 /src
parenta892d2d120b37f8c668ba38011333440e0b1e131 (diff)
MismatchException includes Storable type name in message.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/amazon/carbonado/MismatchException.java36
-rw-r--r--src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableIntrospector.java4
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>