Much improved error reporting when a library is not found.
Example: > (import (a b c)) Unhandled exception Condition components: 1. &error 2. &who: expander 3. &message: "cannot locate library in library-path" 4. &library-resolution: library: (a b c) files: ("./a/b/c.ss" "/Users/ikarus/.opt/lib/ikarus/a/b/c.ss")
This commit is contained in:
parent
ed3641448d
commit
79d529b224
|
@ -336,18 +336,21 @@
|
||||||
(display name p))
|
(display name p))
|
||||||
(let ([v (record-type-field-names rtd)])
|
(let ([v (record-type-field-names rtd)])
|
||||||
(case (vector-length v)
|
(case (vector-length v)
|
||||||
|
[(0) (newline p)]
|
||||||
[(1)
|
[(1)
|
||||||
(display ": " p)
|
(display ": " p)
|
||||||
(write ((record-accessor rtd 0) x) p)]
|
(write ((record-accessor rtd 0) x) p)
|
||||||
|
(newline p)]
|
||||||
[else
|
[else
|
||||||
|
(display ":\n" p)
|
||||||
(let f ([i 0])
|
(let f ([i 0])
|
||||||
(unless (= i (vector-length v))
|
(unless (= i (vector-length v))
|
||||||
(display " " p)
|
(display " " p)
|
||||||
(display (vector-ref v i) p)
|
(display (vector-ref v i) p)
|
||||||
(display "=" p)
|
(display ": " p)
|
||||||
(write ((record-accessor rtd i) x) p)
|
(write ((record-accessor rtd i) x) p)
|
||||||
(f (+ i 1))))]))
|
(newline)
|
||||||
(newline p)))
|
(f (+ i 1))))]))))
|
||||||
(define (print-condition x p)
|
(define (print-condition x p)
|
||||||
(cond
|
(cond
|
||||||
[(condition? x)
|
[(condition? x)
|
||||||
|
|
|
@ -116,12 +116,28 @@
|
||||||
(make-parameter
|
(make-parameter
|
||||||
(lambda (x)
|
(lambda (x)
|
||||||
(let ((str (library-name->file-name x)))
|
(let ((str (library-name->file-name x)))
|
||||||
(let f ((ls (library-path)))
|
(let f ((ls (library-path)) (failed-list '()))
|
||||||
(and (pair? ls)
|
(cond
|
||||||
(let ((name (string-append (car ls) str)))
|
((null? ls)
|
||||||
(if (file-exists? name)
|
(let ()
|
||||||
name
|
(define-condition-type &library-resolution &condition
|
||||||
(f (cdr ls))))))))
|
make-library-resolution-condition
|
||||||
|
library-resolution-condition?
|
||||||
|
(library condition-library)
|
||||||
|
(files condition-files))
|
||||||
|
(raise
|
||||||
|
(condition
|
||||||
|
(make-error)
|
||||||
|
(make-who-condition 'expander)
|
||||||
|
(make-message-condition
|
||||||
|
"cannot locate library in library-path")
|
||||||
|
(make-library-resolution-condition
|
||||||
|
x (reverse failed-list))))))
|
||||||
|
(else
|
||||||
|
(let ((name (string-append (car ls) str)))
|
||||||
|
(if (file-exists? name)
|
||||||
|
name
|
||||||
|
(f (cdr ls) (cons name failed-list)))))))))
|
||||||
(lambda (f)
|
(lambda (f)
|
||||||
(if (procedure? f)
|
(if (procedure? f)
|
||||||
f
|
f
|
||||||
|
|
Loading…
Reference in New Issue