gnu: bootloader: Report error in menu-entry.

* gnu/bootloader.scm (report-menu-entry-error): New procedure.
(menu-entry->sexp): Add a call to `report-menu-entry-error'.

Co-Authored-By: Julien Lepiller <julien@lepiller.eu>
Signed-off-by: Julien Lepiller <julien@lepiller.eu>
This commit is contained in:
tiantian 2022-09-05 01:25:42 +08:00 committed by Julien Lepiller
parent 1fc20e4c86
commit 32da9bbc91
No known key found for this signature in database
GPG Key ID: 53D457B2D636EE82

@ -34,6 +34,8 @@
#:use-module (guix diagnostics) #:use-module (guix diagnostics)
#:use-module (guix i18n) #:use-module (guix i18n)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-34)
#:use-module (srfi srfi-35)
#:use-module (ice-9 match) #:use-module (ice-9 match)
#:export (menu-entry #:export (menu-entry
menu-entry? menu-entry?
@ -110,6 +112,23 @@
(chain-loader menu-entry-chain-loader (chain-loader menu-entry-chain-loader
(default #f))) ; string, path of efi file (default #f))) ; string, path of efi file
(define (report-menu-entry-error menu-entry)
(raise
(condition
(&message
(message
(format #f (G_ "invalid menu-entry: ~a") menu-entry)))
(&fix-hint
(hint
(G_ "Please chose only one of:
@enumerate
@item direct boot by specifying fields @code{linux},
@code{linux-arguments} and @code{linux-modules},
@item multiboot by specifying fields @code{multiboot-kernel},
@code{multiboot-arguments} and @code{multiboot-modules},
@item chain-loader by specifying field @code{chain-loader}.
@end enumerate"))))))
(define (menu-entry->sexp entry) (define (menu-entry->sexp entry)
"Return ENTRY serialized as an sexp." "Return ENTRY serialized as an sexp."
(define (device->sexp device) (define (device->sexp device)
@ -146,7 +165,8 @@
(label ,label) (label ,label)
(device ,(device->sexp device)) (device ,(device->sexp device))
(device-mount-point ,mount-point) (device-mount-point ,mount-point)
(chain-loader ,chain-loader))))) (chain-loader ,chain-loader)))
(_ (report-menu-entry-error entry))))
(define (sexp->menu-entry sexp) (define (sexp->menu-entry sexp)
"Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a <menu-entry> "Turn SEXP, an sexp as returned by 'menu-entry->sexp', into a <menu-entry>