From 0d3612377a51dcee8b67e8923b16ee43227b960b Mon Sep 17 00:00:00 2001 From: mdb Date: Wed, 20 Aug 2008 00:22:41 +0000 Subject: [PATCH] Report a better error message if a bogus rename is attempted. Some formatting cleanup. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2362 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../samskivert/jdbc/depot/EntityMigration.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/java/com/samskivert/jdbc/depot/EntityMigration.java b/src/java/com/samskivert/jdbc/depot/EntityMigration.java index edf2267f..41fc15c2 100644 --- a/src/java/com/samskivert/jdbc/depot/EntityMigration.java +++ b/src/java/com/samskivert/jdbc/depot/EntityMigration.java @@ -101,9 +101,15 @@ public abstract class EntityMigration extends Modifier return true; } - @Override protected void init (String tableName, Map> marshallers) { + @Override + protected void init (String tableName, Map> marshallers) { super.init(tableName, marshallers); - _newColumnDef = marshallers.get(_newColumnName).getColumnDefinition(); + FieldMarshaller fm = marshallers.get(_newColumnName); + if (fm == null) { + throw new IllegalArgumentException( + _tableName + " does not contain '" + _newColumnName + "' field."); + } + _newColumnDef = fm.getColumnDefinition(); } protected String _oldColumnName, _newColumnName; @@ -133,7 +139,8 @@ public abstract class EntityMigration extends Modifier return false; } - @Override protected void init (String tableName, Map> marshallers) { + @Override + protected void init (String tableName, Map> marshallers) { super.init(tableName, marshallers); _columnName = marshallers.get(_fieldName).getColumnName(); _newColumnDef = marshallers.get(_fieldName).getColumnDefinition(); @@ -174,7 +181,7 @@ public abstract class EntityMigration extends Modifier * migration has been determined to be runnable so one cannot rely on this method having been * called in {@link #shouldRunMigration}. */ - protected void init (String tableName, Map> marshallers) + protected void init (String tableName, Map> marshallers) { _tableName = tableName; }