From e69fc3804d93419b8f44035bb8d7a35bf052246a Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Thu, 7 Jun 2007 15:32:29 +0000 Subject: MismatchException includes Storable type name in message. --- .../com/amazon/carbonado/MismatchException.java | 36 ++++++++++++++++++++-- .../repo/jdbc/JDBCStorableIntrospector.java | 4 +-- 2 files changed, 36 insertions(+), 4 deletions(-) (limited to 'src') 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 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 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 -- cgit v1.2.3