@@ -218,12 +218,12 @@ def from_string(self, string):
218218 def check_mandatory_arguments (self , data , ArgClass , tag_name , node ):
219219 for k , v in ArgClass .arguments :
220220 if v != 0 and not ArgClass .map (k ) in data :
221- self .error ("missing element <%s> within <%s> tag" %
221+ self .error ("missing element <%s> within <%s> tag\n " %
222222 (k , tag_name ) + repr (data ), node )
223223
224224 def is_valid_argument (self , tag_name , ArgClass , parent_node , child = None ):
225225 if tag_name not in ArgClass .arguments_keys :
226- self .error ("Invalid element <%s> inside <%s> tag" %
226+ self .error ("Invalid element <%s> inside <%s> tag\n " %
227227 (tag_name , parent_node .tag ),
228228 parent_node if child is None else child )
229229
@@ -247,7 +247,7 @@ def warn(self, msg, elem):
247247
248248 def parse_element (self , node ):
249249 if node .tag not in self .tags :
250- self .error ("Invalid element <%s>" % node .tag , node )
250+ self .error ("Invalid element <%s> " % node .tag , node )
251251 return None # won't be able to parse this one
252252 return getattr (self , "parse_" + node .tag )(node , self .tags [node .tag ])
253253
@@ -273,7 +273,7 @@ def parse_tag(self, root, fmt, insert_children=True):
273273 continue
274274
275275 # We currently do not support XML attributes.
276- self .error ("Attribute not supported, ignoring '%s=%s'" % (k , v ), root )
276+ self .error ("Attribute not supported, ignoring '%s=%s' " % (k , v ), root )
277277
278278 for node in root :
279279 node .tag = node .tag .lower ()
@@ -299,7 +299,7 @@ def parse_tag(self, root, fmt, insert_children=True):
299299 else :
300300 arguments [tag ] = curr_text
301301 else :
302- self .error ("Invalid element <%s> in odML document section <%s>"
302+ self .error ("Invalid element <%s> in odML document section <%s> "
303303 % (node .tag , root .tag ), node )
304304
305305 if sys .version_info > (3 ,):
@@ -310,7 +310,11 @@ def parse_tag(self, root, fmt, insert_children=True):
310310 self .check_mandatory_arguments (check_args , fmt , root .tag , root )
311311
312312 # Instantiate the current odML object with the parsed attributes.
313- obj = fmt .create (** arguments )
313+ obj = fmt .create ()
314+ try :
315+ obj = fmt .create (** arguments )
316+ except Exception as e :
317+ self .error (str (e ), root )
314318
315319 if insert_children :
316320 for child in children :
0 commit comments