Skip to content

Commit 3165456

Browse files
authored
Include HRESULT error code if native .NET initialization fails (#14317)
This is a local patch I used to figure out why it didn't work on my machine. Without the error codes: good luck to figure out what's wrong.
1 parent c461b60 commit 3165456

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/com_dotnet/com_dotnet.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ PHP_METHOD(dotnet, __construct)
245245
if (FAILED(hr)) {
246246
char buf[1024];
247247
char *err = php_win32_error_to_msg(hr);
248-
snprintf(buf, sizeof(buf), "Failed to init .Net runtime [%s] %s", where, err);
248+
snprintf(buf, sizeof(buf), "Failed to init .Net runtime [%s] [0x%08x] %s", where, hr, err);
249249
php_win32_error_msg_free(err);
250250
php_com_throw_exception(hr, buf);
251251
RETURN_THROWS();
@@ -258,7 +258,7 @@ PHP_METHOD(dotnet, __construct)
258258
if (FAILED(hr)) {
259259
char buf[1024];
260260
char *err = php_win32_error_to_msg(hr);
261-
snprintf(buf, sizeof(buf), "Failed to re-init .Net domain [%s] %s", where, err);
261+
snprintf(buf, sizeof(buf), "Failed to re-init .Net domain [%s] [0x%08x] %s", where, hr, err);
262262
php_win32_error_msg_free(err);
263263
php_com_throw_exception(hr, buf);
264264
ZVAL_NULL(object);
@@ -270,7 +270,7 @@ PHP_METHOD(dotnet, __construct)
270270
if (FAILED(hr)) {
271271
char buf[1024];
272272
char *err = php_win32_error_to_msg(hr);
273-
snprintf(buf, sizeof(buf), "Failed to re-init .Net domain [%s] %s", where, err);
273+
snprintf(buf, sizeof(buf), "Failed to re-init .Net domain [%s] [0x%08x] %s", where, hr, err);
274274
php_win32_error_msg_free(err);
275275
php_com_throw_exception(hr, buf);
276276
ZVAL_NULL(object);

0 commit comments

Comments
 (0)