wrap labelFormat formatting in try/catch to present better errors to caller
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 3 Mar 2010 23:00:23 +0000 (23:00 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 3 Mar 2010 23:00:23 +0000 (23:00 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15688 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js

index 49ccf7c..3e5dd90 100644 (file)
@@ -395,12 +395,19 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) {
                             function(item) {
                                 var values = [];
 
-                                // self.labelFormat[1..*] are names of fields.  Pull the field
-                                // values from each object to determine the values for string substitution
-                               for(var i = 1; i< self.labelFormat.length; i++) 
-                                    values.push(item[self.labelFormat[i]]);
+                                try {
 
-                                item._label = dojo.string.substitute(format, values);
+                                    // self.labelFormat[1..*] are names of fields.  Pull the field
+                                    // values from each object to determine the values for string substitution
+                                    for(var i = 1; i< self.labelFormat.length; i++) 
+                                        values.push(item[self.labelFormat[i]]);
+
+                                    item._label = dojo.string.substitute(format, values);
+
+                                } catch(E) {
+                                    throw new Error("openils.widget.AutoFieldWidget: Invalid labelFormat [" + 
+                                        self.labelFormat + "] : " + E);
+                                }
                             }
                         );
                     }