Skip to content

Commit

Permalink
FEAT: better info when native extension fails to load its library
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Nov 13, 2023
1 parent a87e667 commit feaaef9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/boot/errors.reb
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
4 changes: 2 additions & 2 deletions src/core/f-extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion src/mezz/sys-load.reb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit feaaef9

Please sign in to comment.