From b6608db88f0559f7e59b9be859a649f5bb6812b7 Mon Sep 17 00:00:00 2001 From: Thierry Martinez Date: Fri, 26 Feb 2021 23:10:52 +0100 Subject: [PATCH] Better error message on library loading failure --- pyml_stubs.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pyml_stubs.c b/pyml_stubs.c index 9cb696f..81e9d05 100644 --- a/pyml_stubs.c +++ b/pyml_stubs.c @@ -39,7 +39,13 @@ open_library(const char *filename) return LoadLibrary(filename); } -void +static char * +get_library_error() +{ + return "Unable to load library"; +} + +static void close_library(library_t library) { if (!FreeLibrary(library)) { @@ -90,6 +96,12 @@ open_library(const char *filename) return dlopen(filename, RTLD_LAZY | RTLD_GLOBAL); } +static char * +get_library_error() +{ + return dlerror(); +} + void close_library(library_t filename) { @@ -660,7 +672,7 @@ py_load_library(value filename_ocaml, value debug_build_ocaml) const char *filename = String_val(Field(filename_ocaml, 0)); library = open_library(filename); if (!library) { - failwith("Library not found"); + failwith(get_library_error()); } } else {