diff options
author | Wez Furlong <wez@php.net> | 2004-08-03 09:44:04 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2004-08-03 09:44:04 +0000 |
commit | f765acea5951b8007de18649c65df8e49b7eebb4 (patch) | |
tree | d0015cc8091039bcf08d6063822bc773d1678dc6 /ext/com_dotnet | |
parent | cc39d06e4e29c2d8c1cd646d5efc6420816e4365 (diff) | |
download | php-git-f765acea5951b8007de18649c65df8e49b7eebb4.tar.gz |
Even more verbosity in case of error
Diffstat (limited to 'ext/com_dotnet')
-rw-r--r-- | ext/com_dotnet/com_dotnet.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/ext/com_dotnet/com_dotnet.c b/ext/com_dotnet/com_dotnet.c index da142dfeac..b45bce0228 100644 --- a/ext/com_dotnet/com_dotnet.c +++ b/ext/com_dotnet/com_dotnet.c @@ -100,12 +100,12 @@ PHP_FUNCTION(com_dotnet_create_instance) char *assembly_name, *datatype_name; int assembly_name_len, datatype_name_len; struct dotnet_runtime_stuff *stuff; - IObjectHandle *handle; DISPPARAMS params; VARIANT vargs[2]; VARIANT retval; HRESULT hr; int ret = FAILURE; + char *where = ""; if (COMG(dotnet_runtime_stuff) == NULL) { if (FAILURE == dotnet_init(TSRMLS_C)) { @@ -143,27 +143,33 @@ PHP_FUNCTION(com_dotnet_create_instance) V_VT(&vargs[1]) = VT_BSTR; V_BSTR(&vargs[1]) = php_com_string_to_olestring(assembly_name, assembly_name_len, obj->code_page TSRMLS_CC); + where = "IDispatch_Invoke"; hr = IDispatch_Invoke(stuff->dotnet_domain, stuff->create_instance, &IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, ¶ms, &retval, NULL, NULL); if (SUCCEEDED(hr)) { /* retval should now be an IUnknown/IDispatch representation of an IObjectHandle interface */ - if ((V_VT(&retval) == VT_UNKNOWN || V_VT(&retval) == VT_DISPATCH) && - SUCCEEDED(IUnknown_QueryInterface(V_UNKNOWN(&retval), &IID_IObjectHandle, &handle))) { + if (V_VT(&retval) == VT_UNKNOWN || V_VT(&retval) == VT_DISPATCH) { VARIANT unwrapped; + IObjectHandle *handle; - hr = IObjectHandle_Unwrap(handle, &unwrapped); + where = "QI: IID_IObjectHandle"; + hr = IUnknown_QueryInterface(V_UNKNOWN(&retval), &IID_IObjectHandle, &handle); if (SUCCEEDED(hr)) { - /* unwrapped is now the dispatch pointer we want */ - V_DISPATCH(&obj->v) = V_DISPATCH(&unwrapped); - V_VT(&obj->v) = VT_DISPATCH; - - /* get its type-info */ - IDispatch_GetTypeInfo(V_DISPATCH(&obj->v), 0, LANG_NEUTRAL, &obj->typeinfo); - - ret = SUCCESS; + where = "IObjectHandle_Unwrap"; + hr = IObjectHandle_Unwrap(handle, &unwrapped); + if (SUCCEEDED(hr)) { + /* unwrapped is now the dispatch pointer we want */ + V_DISPATCH(&obj->v) = V_DISPATCH(&unwrapped); + V_VT(&obj->v) = VT_DISPATCH; + + /* get its type-info */ + IDispatch_GetTypeInfo(V_DISPATCH(&obj->v), 0, LANG_NEUTRAL, &obj->typeinfo); + + ret = SUCCESS; + } + IObjectHandle_Release(handle); } - IObjectHandle_Release(handle); } VariantClear(&retval); } @@ -172,7 +178,9 @@ PHP_FUNCTION(com_dotnet_create_instance) VariantClear(&vargs[1]); if (ret == FAILURE) { - php_com_throw_exception(hr, "Failed to instantiate .Net object" TSRMLS_CC); + char buf[1024]; + sprintf(buf, "Failed to instantiate .Net object [%s]", where); + php_com_throw_exception(hr, buf TSRMLS_CC); ZVAL_NULL(object); return; } |