mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-12 06:06:53 -05:00
style: Gracefully handle failure to locate a source file.
* guix/scripts/style.scm (absolute-location): Raise an error when 'search-path' returns #f.
This commit is contained in:
parent
4574ef267e
commit
b8b02f4de5
1 changed files with 11 additions and 1 deletions
|
@ -44,6 +44,7 @@ (define-module (guix scripts style)
|
|||
#:use-module (srfi srfi-1)
|
||||
#:use-module (srfi srfi-9)
|
||||
#:use-module (srfi srfi-26)
|
||||
#:use-module (srfi srfi-34)
|
||||
#:use-module (srfi srfi-37)
|
||||
#:export (pretty-print-with-comments
|
||||
read-with-comments
|
||||
|
@ -683,7 +684,16 @@ (define (absolute-location loc)
|
|||
"Replace the file name in LOC by an absolute location."
|
||||
(location (if (string-prefix? "/" (location-file loc))
|
||||
(location-file loc)
|
||||
(search-path %load-path (location-file loc)))
|
||||
|
||||
;; 'search-path' might return #f in obscure cases, such as
|
||||
;; when %LOAD-PATH includes "." or ".." and LOC comes from a
|
||||
;; file in a subdirectory thereof.
|
||||
(match (search-path %load-path (location-file loc))
|
||||
(#f
|
||||
(raise (formatted-message
|
||||
(G_ "file '~a' not found on load path")
|
||||
(location-file loc))))
|
||||
(str str)))
|
||||
(location-line loc)
|
||||
(location-column loc)))
|
||||
|
||||
|
|
Loading…
Reference in a new issue