From feaaef940490166984aaff4c9a654324703fbc4b Mon Sep 17 00:00:00 2001 From: Oldes Huhuman Date: Mon, 13 Nov 2023 11:29:41 +0100 Subject: [PATCH] FEAT: better info when native extension fails to load its library related to: https://github.com/Oldes/Rebol-issues/issues/2579 --- src/boot/errors.reb | 2 +- src/core/f-extension.c | 4 ++-- src/mezz/sys-load.reb | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/boot/errors.reb b/src/boot/errors.reb index 344eb9f7de..72b2f01195 100644 --- a/src/boot/errors.reb +++ b/src/boot/errors.reb @@ -190,7 +190,7 @@ Access: [ ; would-block: [{operation on port} :arg1 {would block}] ; no-action: [{this type of port does not support the} :arg1 {action}] ; serial-timeout: {serial port timeout} - no-extension: [{cannot open extension:} :arg1] + no-extension: [{cannot open extension:} :arg1 {reason:} :arg2] bad-extension: [{invalid extension format:} :arg1] extension-init: [{extension cannot be initialized (check version):} :arg1] diff --git a/src/core/f-extension.c b/src/core/f-extension.c index a49ae73c48..c9dd2c9da6 100644 --- a/src/core/f-extension.c +++ b/src/core/f-extension.c @@ -361,8 +361,8 @@ x*/ int Do_Callback(REBSER *obj, u32 name, RXIARG *args, RXIARG *result) // Try to load the DLL file: if (!(dll = OS_OPEN_LIBRARY((REBCHR*)SERIES_DATA(path), &error))) { - //printf("error: %i\n", error); - Trap1(RE_NO_EXTENSION, val); + DS_PUSH_INTEGER(error); + Trap2(RE_NO_EXTENSION, val, DS_TOP); } // Call its info() function for header and code body: diff --git a/src/mezz/sys-load.reb b/src/mezz/sys-load.reb index 98b721dde5..324bc461cd 100644 --- a/src/mezz/sys-load.reb +++ b/src/mezz/sys-load.reb @@ -489,7 +489,10 @@ load-module: function [ not tmp [unless attempt [data: read source] [return none]] tmp = 'extension [ ; special processing for extensions ; load-extension also fails for url! - unless attempt [ext: load-extension source] [return none] + try/with [ext: load-extension source] [ + log/error 'REBOL system/state/last-error + return none + ] data: ext/lib-boot ; save for checksum before it's unset case [ import [set [hdr: code:] load-ext-module ext]