Skip to content

Commit b6608db

Browse files
Better error message on library loading failure
1 parent 2be0a2f commit b6608db

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pyml_stubs.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ open_library(const char *filename)
3939
return LoadLibrary(filename);
4040
}
4141

42-
void
42+
static char *
43+
get_library_error()
44+
{
45+
return "Unable to load library";
46+
}
47+
48+
static void
4349
close_library(library_t library)
4450
{
4551
if (!FreeLibrary(library)) {
@@ -90,6 +96,12 @@ open_library(const char *filename)
9096
return dlopen(filename, RTLD_LAZY | RTLD_GLOBAL);
9197
}
9298

99+
static char *
100+
get_library_error()
101+
{
102+
return dlerror();
103+
}
104+
93105
void
94106
close_library(library_t filename)
95107
{
@@ -660,7 +672,7 @@ py_load_library(value filename_ocaml, value debug_build_ocaml)
660672
const char *filename = String_val(Field(filename_ocaml, 0));
661673
library = open_library(filename);
662674
if (!library) {
663-
failwith("Library not found");
675+
failwith(get_library_error());
664676
}
665677
}
666678
else {

0 commit comments

Comments
 (0)