From 0b91f0f6a79781b01d8fb10a81d2df4ee00e19eb Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 14 Aug 2007 18:47:21 +0000 Subject: [PATCH] Use IllegalArgumentException since those are basically illegal arguments. Also use @exception because it's a nice way to let humans and tools know what's going on. --- .../com/samskivert/jdbc/depot/DepotTypes.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/java/com/samskivert/jdbc/depot/DepotTypes.java b/src/java/com/samskivert/jdbc/depot/DepotTypes.java index 7c0920f..b2d9d40 100644 --- a/src/java/com/samskivert/jdbc/depot/DepotTypes.java +++ b/src/java/com/samskivert/jdbc/depot/DepotTypes.java @@ -102,13 +102,12 @@ public class DepotTypes * Return the current abbreviation by which we refer to the table associated with the given * persistent record -- which must have been previously registered with this object. If the * useTableAbbreviations flag is false, we return the full table name instead. + * + * @exception IllegalArgumentException thrown if the specified class is not known. */ public String getTableAbbreviation (Class cl) { if (_useTableAbbreviations) { - if (!_classIx.containsKey(cl)) { - throw new RuntimeException("Persistent class not known: " + cl); - } Integer ix = _classIx.get(cl); if (ix == null) { throw new IllegalArgumentException("Unknown persistence class: " + cl); @@ -122,26 +121,31 @@ public class DepotTypes * Return the associated database column of the given field of the given persistent class, * throwing an exception if the record has not been registered with this object, or if the * field is unknown on the record. + * + * @exception IllegalArgumentException thrown if the specified field is not part of the + * specified persistent class. */ public String getColumnName (Class cl, String field) { FieldMarshaller fm = getMarshaller(cl).getFieldMarshaller(field); if (fm == null) { - throw new RuntimeException( + throw new IllegalArgumentException( "Field not known on class [field=" + field + ", class=" + cl + "]"); } return fm.getColumnName(); } /** - * Return the {@link DepotMarshaller} associated with the given persistent class, if it's - * been registered with this object, otherwise throw an exception. + * Return the {@link DepotMarshaller} associated with the given persistent class, if it's been + * registered with this object. + * + * @exception IllegalArgumentException thrown if the specified class is not known. */ public DepotMarshaller getMarshaller (Class cl) { DepotMarshaller marsh = _classMap.get(cl); if (marsh == null) { - throw new RuntimeException("Persistent class not known: " + cl); + throw new IllegalArgumentException("Persistent class not known: " + cl); } return marsh; }