guix system: Report file system errors using 'report-error'.

* guix/scripts/system.scm (check-file-system-availability)[file-system-location*]:
Return a <location> record instead of a string.
[error]: Use 'report-error' instead of 'format'.
Change callers accordingly.
This commit is contained in:
Ludovic Courtès 2020-07-25 18:37:30 +02:00
parent d51bfe242f
commit 9a6322774d
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 11 additions and 12 deletions

View File

@ -565,16 +565,14 @@ any, are available. Raise an error if they're not."
(define fail? #f) (define fail? #f)
(define (file-system-location* fs) (define (file-system-location* fs)
(location->string (and=> (file-system-location fs)
(source-properties->location source-properties->location))
(file-system-location fs))))
(let-syntax ((error (syntax-rules () (let-syntax ((error (syntax-rules ()
((_ args ...) ((_ args ...)
(begin (begin
(set! fail? #t) (set! fail? #t)
(format (current-error-port) (report-error args ...))))))
args ...))))))
(for-each (lambda (fs) (for-each (lambda (fs)
(catch 'system-error (catch 'system-error
(lambda () (lambda ()
@ -582,9 +580,9 @@ any, are available. Raise an error if they're not."
(lambda args (lambda args
(let ((errno (system-error-errno args)) (let ((errno (system-error-errno args))
(device (file-system-device fs))) (device (file-system-device fs)))
(error (G_ "~a: error: device '~a' not found: ~a~%") (error (file-system-location* fs)
(file-system-location* fs) device (G_ "device '~a' not found: ~a~%")
(strerror errno)) device (strerror errno))
(unless (string-prefix? "/" device) (unless (string-prefix? "/" device)
(display-hint (format #f (G_ "If '~a' is a file system (display-hint (format #f (G_ "If '~a' is a file system
label, write @code{(file-system-label ~s)} in your @code{device} field.") label, write @code{(file-system-label ~s)} in your @code{device} field.")
@ -594,13 +592,14 @@ label, write @code{(file-system-label ~s)} in your @code{device} field.")
(let ((label (file-system-label->string (let ((label (file-system-label->string
(file-system-device fs)))) (file-system-device fs))))
(unless (find-partition-by-label label) (unless (find-partition-by-label label)
(error (G_ "~a: error: file system with label '~a' not found~%") (error (file-system-location* fs)
(file-system-location* fs) label)))) (G_ "file system with label '~a' not found~%")
label))))
labeled) labeled)
(for-each (lambda (fs) (for-each (lambda (fs)
(unless (find-partition-by-uuid (file-system-device fs)) (unless (find-partition-by-uuid (file-system-device fs))
(error (G_ "~a: error: file system with UUID '~a' not found~%") (error (file-system-location* fs)
(file-system-location* fs) (G_ "file system with UUID '~a' not found~%")
(uuid->string (file-system-device fs))))) (uuid->string (file-system-device fs)))))
uuid) uuid)