More descriptive error for dynamic-pointer
authorMichael Gran <spk121@yahoo.com>
Thu, 31 Mar 2011 03:42:37 +0000 (20:42 -0700)
committerAndy Wingo <wingo@pobox.com>
Thu, 31 Mar 2011 10:34:47 +0000 (12:34 +0200)
* libguile/dynl.c (sysdep_dynl_value): Failure to find a symbol is not
  an error, so raise our own, more appropriate error.

* test-suite/tests/foreign.test ("dynamic-pointer"): Add a test.

libguile/dynl.c
test-suite/tests/foreign.test

index 2484dda..a2ae6e2 100644 (file)
@@ -115,9 +115,8 @@ sysdep_dynl_value (const char *symb, void *handle, const char *subr)
 
   fptr = lt_dlsym ((lt_dlhandle) handle, symb);
   if (!fptr)
-    {
-      scm_misc_error (subr, (char *) lt_dlerror (), SCM_EOL);
-    }
+    scm_misc_error (subr, "Symbol not found: ~a",
+                    scm_list_1 (scm_from_locale_string (symb)));
   return fptr;
 }
 
index 93e5fe1..1353e7d 100644 (file)
   #:use-module (test-suite lib))
 
 \f
+(with-test-prefix "dynamic-pointer"
+
+  (pass-if-exception
+   "error message"
+   '(misc-error . "^Symbol not found")
+   (dynamic-func "does_not_exist___" (dynamic-link))))
+
+\f
 (with-test-prefix "null pointer"
 
   (pass-if "pointer?"