msxml3: Improve parse error handling a bit

Huw D M Davies h.davies1 at physics.ox.ac.uk
Tue Feb 21 05:52:25 CST 2006


        Huw Davies <huw at codeweavers.com>
        msxml3: Improve parse error handling a bit.
-- 
Huw Davies
huw at codeweavers.com
diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c
index bfccc1e..8f0604a 100644
--- a/dlls/msxml3/domdoc.c
+++ b/dlls/msxml3/domdoc.c
@@ -168,6 +168,7 @@ typedef struct _domdoc
     VARIANT_BOOL async;
     IUnknown *node_unk;
     IXMLDOMNode *node;
+    HRESULT error;
 } domdoc;
 
 LONG xmldoc_add_ref(xmlDocPtr doc)
@@ -978,8 +979,13 @@ static HRESULT WINAPI domdoc_load(
         return S_FALSE;
 
     xmldoc = doread( filename );
-    if ( !xmldoc ) return S_FALSE;
+    if ( !xmldoc )
+    {
+        This->error = E_FAIL;
+        return S_FALSE;
+    }
 
+    This->error = S_OK;
     xmldoc->_private = 0;
     attach_xmlnode(This->node, (xmlNodePtr) xmldoc);
 
@@ -1001,8 +1007,16 @@ static HRESULT WINAPI domdoc_get_parseEr
     IXMLDOMDocument *iface,
     IXMLDOMParseError** errorObj )
 {
+    BSTR error_string = NULL;
+    static const WCHAR err[] = {'e','r','r','o','r',0};
+    domdoc *This = impl_from_IXMLDOMDocument( iface );
+
     FIXME("(%p)->(%p): creating a dummy parseError\n", iface, errorObj);
-    *errorObj = create_parseError(0, NULL, NULL, NULL, 0, 0, 0);
+
+    if(This->error)
+        error_string = SysAllocString(err);
+
+    *errorObj = create_parseError(This->error, NULL, error_string, NULL, 0, 0, 0);
     if(!*errorObj) return E_OUTOFMEMORY;
     return S_OK;
 }
@@ -1094,8 +1108,12 @@ static HRESULT WINAPI domdoc_loadXML(
     xmldoc = doparse( str, len );
     HeapFree( GetProcessHeap(), 0, str );
     if ( !xmldoc )
+    {
+        This->error = E_FAIL;
         return S_FALSE;
+    }
 
+    This->error = S_OK;
     xmldoc->_private = 0;
     attach_xmlnode( This->node, (xmlNodePtr) xmldoc );
 
@@ -1317,6 +1335,7 @@ HRESULT DOMDocument_create(IUnknown *pUn
     doc->lpVtbl = &domdoc_vtbl;
     doc->ref = 1;
     doc->async = 0;
+    doc->error = S_OK;
 
     doc->node_unk = create_basic_node( NULL, (IUnknown*)&doc->lpVtbl );
     if(!doc->node_unk)
diff --git a/dlls/msxml3/parseerror.c b/dlls/msxml3/parseerror.c
index acde7cc..240d1fe 100644
--- a/dlls/msxml3/parseerror.c
+++ b/dlls/msxml3/parseerror.c
@@ -173,8 +173,16 @@ static HRESULT WINAPI parseError_get_rea
     IXMLDOMParseError *iface,
     BSTR *reason )
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    parse_error_t *This = impl_from_IXMLDOMParseError( iface );
+    TRACE("(%p)->(%p)\n", This, reason);
+    
+    if(!This->reason)
+    {
+        *reason = NULL;
+        return S_FALSE;
+    }
+    *reason = SysAllocString(This->reason);
+    return S_OK;
 }
 
 static HRESULT WINAPI parseError_get_srcText(



More information about the wine-patches mailing list