@@ -44,7 +44,7 @@ class UnknownWidgetDefinition(Exception):
4444
4545
4646class DeserializationWarning (UserWarning ):
47- pass
47+ node = None # type: Optional[SchemeNode]
4848
4949
5050class PickleDataWarning (DeserializationWarning ):
@@ -513,23 +513,29 @@ def error_handler(exc):
513513 if data is not None :
514514 try :
515515 properties = data_deserializer (data .data , data .format )
516- except UnsupportedPickleFormatError :
517- log .error ("Could not load pickled properties for %r." , node .title ,
518- exc_info = True )
519- warning_handler (
520- PickleDataWarning (
521- "The file contains pickle data. The settings for '{}' "
522- "were not restored." .format (node_d .title )
516+ except UnsupportedFormatError as err :
517+ err .node = node
518+ err .args = err .args + (node ,)
519+ error_handler (err )
520+ if isinstance (err , UnsupportedPickleFormatError ):
521+ warning = PickleDataWarning (
522+ "The file contains pickle data. The settings "
523+ "for '{}' were not restored." .format (node_d .title )
523524 )
524- )
525- except Exception as err : # pylint: disable=broad-except
526- log .error ("Could not load properties for %r." , node .title ,
527- exc_info = True )
528- warning_handler (
529- DeserializationWarning (
530- "Could not load properties for %r." , node .title
525+ else :
526+ warning = DeserializationWarning (
527+ "Could not load properties for %r" .format (node .title ),
531528 )
529+ warning .node = node
530+ warning_handler (warning )
531+ node .setProperty ("__ows_data_deserialization_error" , (type (err ), err .args ))
532+ except Exception as err : # pylint: disable=broad-except
533+ error_handler (err )
534+ warning = DeserializationWarning (
535+ "Could not load properties for %r." , node .title
532536 )
537+ warning .node = node
538+ warning_handler (node )
533539 node .setProperty ("__ows_data_deserialization_error" , (type (err ), err .args ))
534540 else :
535541 node .properties = properties
@@ -887,18 +893,18 @@ def indent_(element, level, last):
887893
888894
889895class UnsupportedFormatError (ValueError ):
890- pass
896+ node = None # type: Optional[SchemeNode]
891897
892898
893899class UnsupportedPickleFormatError (UnsupportedFormatError ): ...
894900
895901
896902class UnserializableValueError (ValueError ):
897- pass
903+ node = None # type: Optional[SchemeNode]
898904
899905
900906class UnserializableTypeError (TypeError ):
901- pass
907+ node = None # type: Optional[SchemeNode]
902908
903909
904910def dumps (obj , format = "literal" , indent = 4 ):
0 commit comments