summary refs log tree commit diff
path: root/gnu/system.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-03-16 15:03:01 +0100
committerLudovic Courtès <ludo@gnu.org>2022-03-16 15:48:52 +0100
commit47960b55268220ca1cb7d2fed41c53873181d816 (patch)
treea0ca790a00c22231eabc008d6cf3f5fa60830c5f /gnu/system.scm
parent5d4af22ef21b71556e0f9a2ddc2d33366858813b (diff)
downloadguix-47960b55268220ca1cb7d2fed41c53873181d816.tar.gz
system: Improve 'read-boot-parameters' incompatibility diagnostic.
Previously, when reading an incompatible "parameters" file, 'guix
system' would print a warning and then crash with a wrong-type-arg
backtrace because code expects 'read-boot-parameters' to always return a
<boot-parameters> record.

* gnu/system.scm (read-boot-parameters): Upon incompatibility, raise an
error instead of returning #f.  Also raise a '&fix-hint' condition.
* tests/boot-parameters.scm ("read, construction, mandatory fields"):
Define 'test-read-boot-parameters' as a macro; expect
'formatted-message?' exceptions rather than #f returns.
Diffstat (limited to 'gnu/system.scm')
-rw-r--r--gnu/system.scm19
1 files changed, 15 insertions, 4 deletions
diff --git a/gnu/system.scm b/gnu/system.scm
index dc980312ab..59b3dea93c 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -354,7 +354,7 @@ file system labels."
 
 (define (read-boot-parameters port)
   "Read boot parameters from PORT and return the corresponding
-<boot-parameters> object or #f if the format is unrecognized."
+<boot-parameters> object.  Raise an error if the format is unrecognized."
   (define device-sexp->device
     (match-lambda
       (('uuid (? symbol? type) (? bytevector? bv))
@@ -481,9 +481,20 @@ file system labels."
          (_                                       ;the old format
           "/")))))
     (x                                            ;unsupported format
-     (warning (G_ "unrecognized boot parameters at '~a'~%")
-              (port-filename port))
-     #f)))
+     (raise
+      (make-compound-condition
+       (formatted-message
+        (G_ "unrecognized boot parameters at '~a'~%")
+        (port-filename port))
+       (condition
+        (&fix-hint (hint (format #f (G_ "This probably means that this version
+of Guix is older than the one that created @file{~a}.  To address this, you
+need to update Guix:
+
+@example
+guix pull
+@end example")
+                                 (port-filename port))))))))))
 
 (define (read-boot-parameters-file system)
   "Read boot parameters from SYSTEM's (system or generation) \"parameters\"