Browse code

- improved error message when select cannot be parsed

Tomas Mandys authored on 27/02/2006 20:50:36
Showing 1 changed files
... ...
@@ -20,8 +20,8 @@
20 20
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 21
  * GNU General Public License for more details.
22 22
  *
23
- * You should have received a copy of the GNU General Public License 
24
- * along with this program; if not, write to the Free Software 
23
+ * You should have received a copy of the GNU General Public License
24
+ * along with this program; if not, write to the Free Software
25 25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 26
  *
27 27
  * History:
... ...
@@ -55,7 +55,7 @@ int resolve_select(select_t* s)
55 55
 	int table_idx = 0;
56 56
 	select_table_t* t = NULL;;
57 57
 	int accept = 0;
58
-	
58
+
59 59
 	f = NULL;
60 60
 	nested = 0;
61 61
 	s->f[0] = NULL;
... ...
@@ -73,7 +73,7 @@ int resolve_select(select_t* s)
73 73
 			break;
74 74
 		}
75 75
 		for (t=select_list; t; t=t->next) {
76
-			table_idx = 0;	
76
+			table_idx = 0;
77 77
 			if (!t->table) continue;
78 78
 			while (t->table[table_idx].curr_f || t->table[table_idx].new_f) {
79 79
 				if (t->table[table_idx].curr_f == f) {
... ...
@@ -97,7 +97,18 @@ int resolve_select(select_t* s)
97 97
 				table_idx++;
98 98
 			}
99 99
 		}
100
-		BUG ("Unable to resolve select at level %d\n", param_idx);
100
+		switch (s->params[param_idx].type) {
101
+			case SEL_PARAM_STR:
102
+				LOG(L_ERR, "Unable to resolve select '%.*s' at level %d\n", s->params[param_idx].v.s.len, s->params[param_idx].v.s.s, param_idx);
103
+				break;
104
+			case SEL_PARAM_INT:
105
+				LOG(L_ERR, "Unable to resolve select [%d] at level %d\n", s->params[param_idx].v.i, param_idx);
106
+				break;
107
+			default:
108
+				BUG ("Unable to resolve select at level %d\n", param_idx);
109
+				break;
110
+			break;
111
+		}
101 112
 		goto not_found;
102 113
 
103 114
 		accepted:
... ...
@@ -109,7 +120,7 @@ int resolve_select(select_t* s)
109 120
 			 */
110 121
 			s->params[param_idx].type = SEL_PARAM_DIV;
111 122
 			s->params[param_idx].v.i = t->table[table_idx].flags & DIVERSION_MASK;
112
-			
123
+
113 124
 		}
114 125
 		if (t->table[table_idx].flags & CONSUME_NEXT_STR) {
115 126
 			if ((param_idx<s->n-1) && (s->params[param_idx+1].type == SEL_PARAM_STR)) {
... ...
@@ -130,7 +141,7 @@ int resolve_select(select_t* s)
130 141
 		if (t->table[table_idx].flags & FIXUP_CALL) {
131 142
 			if (t->table[table_idx].new_f(NULL, s, NULL)<0) goto not_found;
132 143
 		}
133
-		
144
+
134 145
 		if (t->table[table_idx].flags & NESTED) {
135 146
 			if (nested < MAX_NESTED_CALLS-1) { /* need space for final function */
136 147
 				s->f[nested++] = f;
... ...
@@ -158,9 +169,9 @@ int resolve_select(select_t* s)
158 169
 	} else {
159 170
 		s->f[nested] = f;
160 171
 	}
161
-		
172
+
162 173
 	return 0;
163
-	
174
+
164 175
 not_found:
165 176
 	return -1;
166 177
 }
... ...
@@ -168,7 +179,7 @@ not_found:
168 179
 int run_select(str* res, select_t* s, struct sip_msg* msg)
169 180
 {
170 181
 	int ret, i;
171
-	
182
+
172 183
 	if (res == NULL) {
173 184
 		BUG("Select unprepared result space\n");
174 185
 		return -1;
... ...
@@ -212,7 +223,7 @@ int register_select_table(select_row_t* mod_tab)
212 223
 		ERR("No memory for new select_table structure\n");
213 224
 		return -1;
214 225
 	}
215
-	
226
+
216 227
 	t->table=mod_tab;
217 228
 	t->next=select_list;
218 229
 	select_list=t;