diff options
author | Justin Clark-Casey (justincc) | 2012-02-03 23:47:01 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-02-03 23:47:01 +0000 |
commit | 312e1457dd576bc61ac2fd2e104813dd86134c4d (patch) | |
tree | a67d8bbdf782d5d276a2da4f6ea9d1d191ca0762 /OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs | |
parent | Extend m_avatars lock in NpcModule.CreateNPC over both creation of NPC scene ... (diff) | |
download | opensim-SC-312e1457dd576bc61ac2fd2e104813dd86134c4d.zip opensim-SC-312e1457dd576bc61ac2fd2e104813dd86134c4d.tar.gz opensim-SC-312e1457dd576bc61ac2fd2e104813dd86134c4d.tar.bz2 opensim-SC-312e1457dd576bc61ac2fd2e104813dd86134c4d.tar.xz |
Change SceneObjectSerializer to use common ExternalRepresentationUtils.ExecuteReadProcessors() methods.
Adds ability to submit a customized exception message to match logging.
Diffstat (limited to 'OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs')
-rw-r--r-- | OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs index 39a9f37..a392af6 100644 --- a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs +++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs | |||
@@ -47,15 +47,36 @@ namespace OpenSim.Framework.Serialization.External | |||
47 | /// Populate a node with data read from xml using a dictinoary of processors | 47 | /// Populate a node with data read from xml using a dictinoary of processors |
48 | /// </summary> | 48 | /// </summary> |
49 | /// <param name="nodeToFill"></param> | 49 | /// <param name="nodeToFill"></param> |
50 | /// <param name="processors"> | 50 | /// <param name="processors">/param> |
51 | /// A <see cref="Dictionary<System.String, Action<NodeType, XmlTextReader>>"/> | 51 | /// <param name="xtr"></param> |
52 | /// </param> | ||
53 | /// <param name="xtr"> | ||
54 | /// A <see cref="XmlTextReader"/> | ||
55 | /// </param> | ||
56 | public static void ExecuteReadProcessors<NodeType>( | 52 | public static void ExecuteReadProcessors<NodeType>( |
57 | NodeType nodeToFill, Dictionary<string, Action<NodeType, XmlTextReader>> processors, XmlTextReader xtr) | 53 | NodeType nodeToFill, Dictionary<string, Action<NodeType, XmlTextReader>> processors, XmlTextReader xtr) |
58 | { | 54 | { |
55 | ExecuteReadProcessors( | ||
56 | nodeToFill, | ||
57 | processors, | ||
58 | xtr, | ||
59 | (o, name, e) | ||
60 | => m_log.ErrorFormat( | ||
61 | "[ExternalRepresentationUtils]: Exception while parsing element {0}, continuing. Exception {1}{2}", | ||
62 | name, e.Message, e.StackTrace)); | ||
63 | } | ||
64 | |||
65 | /// <summary> | ||
66 | /// Populate a node with data read from xml using a dictinoary of processors | ||
67 | /// </summary> | ||
68 | /// <param name="nodeToFill"></param> | ||
69 | /// <param name="processors"></param> | ||
70 | /// <param name="xtr"></param> | ||
71 | /// <param name="parseExceptionAction"> | ||
72 | /// Action to take if there is a parsing problem. This will usually just be to log the exception | ||
73 | /// </param> | ||
74 | public static void ExecuteReadProcessors<NodeType>( | ||
75 | NodeType nodeToFill, | ||
76 | Dictionary<string, Action<NodeType, XmlTextReader>> processors, | ||
77 | XmlTextReader xtr, | ||
78 | Action<NodeType, string, Exception> parseExceptionAction) | ||
79 | { | ||
59 | string nodeName = string.Empty; | 80 | string nodeName = string.Empty; |
60 | while (xtr.NodeType != XmlNodeType.EndElement) | 81 | while (xtr.NodeType != XmlNodeType.EndElement) |
61 | { | 82 | { |
@@ -74,9 +95,7 @@ namespace OpenSim.Framework.Serialization.External | |||
74 | } | 95 | } |
75 | catch (Exception e) | 96 | catch (Exception e) |
76 | { | 97 | { |
77 | m_log.ErrorFormat( | 98 | parseExceptionAction(nodeToFill, nodeName, e); |
78 | "[ExternalRepresentationUtils]: Exception while parsing element {0}, continuing. Exception {1}{2}", | ||
79 | nodeName, e.Message, e.StackTrace); | ||
80 | 99 | ||
81 | if (xtr.NodeType == XmlNodeType.EndElement) | 100 | if (xtr.NodeType == XmlNodeType.EndElement) |
82 | xtr.Read(); | 101 | xtr.Read(); |