more helpful error messages on missing libraries

This commit is contained in:
Alex Shinn 2019-04-21 22:11:11 +08:00
parent 4cba9d3e6c
commit 105a4672e7
2 changed files with 24 additions and 2 deletions

View file

@ -310,7 +310,29 @@
(lambda (a b)
(string<? (write-to-string a) (write-to-string b))))))
(else
(display "... none found.\n" out))))))))))
(display "... none found.\n" out))))))))
((and (exception? exn)
(equal? "couldn't find import" (exception-message exn))
(pair? (exception-irritants exn)))
(let* ((mod-name (car (exception-irritants exn)))
(mod-file (module-name->file mod-name))
(scm-file (string-append
(substring mod-file
0
(- (string-length mod-file) 4))
".scm")))
(display "Searched module path " out)
(display (current-module-path) out)
(display " for " out)
(write mod-file out)
(display ".\n" out)
(cond
((find-module-file scm-file)
=> (lambda (file)
(display "But found non-module-definition file " out)
(write file out)
(display ".\nNote module files must end in \".sld\".\n" out)))))
)))
(define undefined-value (if #f #f))

View file

@ -1,7 +1,7 @@
(define-library (chibi repl)
(export repl $0 $1 $2 $3 $4 $5 $6 $7 $8 $9)
(import (chibi) (only (meta) load-module)
(import (chibi) (only (meta) load-module module-name->file)
(chibi ast) (chibi modules) (chibi doc)
(chibi string) (chibi io) (chibi optional)
(chibi process) (chibi term edit-line)