packages: Raise an error condition upon invalid input.
* guix/packages.scm (&package-error, &package-input-error): New condition types. (package-derivation): Raise a `&package-input-error' when no match is made.
This commit is contained in:
parent
dfae21c8cc
commit
d36622dc44
|
@ -23,6 +23,8 @@
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (srfi srfi-9)
|
#:use-module (srfi srfi-9)
|
||||||
|
#:use-module (srfi srfi-34)
|
||||||
|
#:use-module (srfi srfi-35)
|
||||||
#:export (location
|
#:export (location
|
||||||
location?
|
location?
|
||||||
location-file
|
location-file
|
||||||
|
@ -60,7 +62,12 @@
|
||||||
package-transitive-inputs
|
package-transitive-inputs
|
||||||
package-source-derivation
|
package-source-derivation
|
||||||
package-derivation
|
package-derivation
|
||||||
package-cross-derivation))
|
package-cross-derivation
|
||||||
|
|
||||||
|
&package-error
|
||||||
|
package-error-package
|
||||||
|
&package-input-error
|
||||||
|
package-error-invalid-input))
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
;;;
|
;;;
|
||||||
|
@ -116,6 +123,7 @@ representation."
|
||||||
#''bv)))))
|
#''bv)))))
|
||||||
|
|
||||||
;; A package.
|
;; A package.
|
||||||
|
|
||||||
(define-record-type* <package>
|
(define-record-type* <package>
|
||||||
package make-package
|
package make-package
|
||||||
package?
|
package?
|
||||||
|
@ -156,6 +164,18 @@ representation."
|
||||||
(default (and=> (current-source-location)
|
(default (and=> (current-source-location)
|
||||||
source-properties->location))))
|
source-properties->location))))
|
||||||
|
|
||||||
|
|
||||||
|
;; Error conditions.
|
||||||
|
|
||||||
|
(define-condition-type &package-error &error
|
||||||
|
package-error?
|
||||||
|
(package package-error-package))
|
||||||
|
|
||||||
|
(define-condition-type &package-input-error &package-error
|
||||||
|
package-input-error?
|
||||||
|
(input package-error-invalid-input))
|
||||||
|
|
||||||
|
|
||||||
(define (package-source-derivation store source)
|
(define (package-source-derivation store source)
|
||||||
"Return the derivation path for SOURCE, a package source."
|
"Return the derivation path for SOURCE, a package source."
|
||||||
(match source
|
(match source
|
||||||
|
@ -209,7 +229,11 @@ with their propagated inputs, recursively."
|
||||||
;; added anyway, so it can be used as a source.
|
;; added anyway, so it can be used as a source.
|
||||||
(list name
|
(list name
|
||||||
(add-to-store store (basename file)
|
(add-to-store store (basename file)
|
||||||
#t #f "sha256" file))))
|
#t #f "sha256" file)))
|
||||||
|
(x
|
||||||
|
(raise (condition (&package-input-error
|
||||||
|
(package package)
|
||||||
|
(input x))))))
|
||||||
(package-transitive-inputs package))))
|
(package-transitive-inputs package))))
|
||||||
(apply builder
|
(apply builder
|
||||||
store (string-append name "-" version)
|
store (string-append name "-" version)
|
||||||
|
|
Loading…
Reference in New Issue