diff options
author | Ludovic Courtès <ludo@gnu.org> | 2020-07-25 18:26:18 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2020-07-25 19:11:37 +0200 |
commit | d51bfe242fbe6f3f8f71d723e8fe0c7bbe711ba1 (patch) | |
tree | 6d8519ba2ab3e5475ff44dfa3a1c2aa9ec8a50b9 /gnu | |
parent | 252a1926bc7d7aa0b39d89a484c0c1b82e945fcd (diff) | |
download | guix-d51bfe242fbe6f3f8f71d723e8fe0c7bbe711ba1.tar guix-d51bfe242fbe6f3f8f71d723e8fe0c7bbe711ba1.tar.gz |
Use 'formatted-message' instead of '&message' where appropriate.
* gnu.scm (%try-use-modules): Use 'formatted-message' instead of
'&message'.
* gnu/machine/digital-ocean.scm (maybe-raise-unsupported-configuration-error):
Likewise.
* gnu/machine/ssh.scm (machine-check-file-system-availability): Likewise.
(machine-check-building-for-appropriate-system): Likewise.
(deploy-managed-host): Likewise.
(maybe-raise-unsupported-configuration-error): Likewise.
* gnu/packages.scm (search-patch): Likewise.
* gnu/services.scm (%service-with-default-value): Likewise.
(files->etc-directory): Likewise.
(fold-services): Likewise.
* gnu/system.scm (locale-name->definition*): Likewise.
* gnu/system/mapped-devices.scm (check-device-initrd-modules): Likewise.
(check-luks-device): Likewise.
* guix/channels.scm (latest-channel-instance): Likewise.
* guix/cve.scm (json->cve-items): Likewise.
* guix/git-authenticate.scm (commit-signing-key): Likewise.
(commit-authorized-keys): Likewise.
(authenticate-commit): Likewise.
(verify-introductory-commit): Likewise.
* guix/remote.scm (remote-pipe-for-gexp): Likewise.
* guix/scripts/graph.scm (assert-package): Likewise.
* guix/scripts/offload.scm (private-key-from-file*): Likewise.
* guix/ssh.scm (authenticate-server*): Likewise.
(open-ssh-session): Likewise.
(remote-inferior): Likewise.
* guix/ui.scm (matching-generations): Likewise.
* guix/upstream.scm (package-update): Likewise.
* tests/channels.scm ("latest-channel-instances, missing introduction for 'guix'"):
Catch 'formatted-message?'.
("authenticate-channel, wrong first commit signer"): Likewise.
* tests/lint.scm ("patches: not found"): Adjust message string.
* tests/packages.scm ("patch not found yields a run-time error"): Catch
'formatted-message?'.
* guix/lint.scm (check-patch-file-names): Handle 'formatted-message?'.
(check-derivation): Ditto.
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/machine/digital-ocean.scm | 7 | ||||
-rw-r--r-- | gnu/machine/ssh.scm | 36 | ||||
-rw-r--r-- | gnu/packages.scm | 6 | ||||
-rw-r--r-- | gnu/services.scm | 32 | ||||
-rw-r--r-- | gnu/system.scm | 4 | ||||
-rw-r--r-- | gnu/system/mapped-devices.scm | 34 |
6 files changed, 52 insertions, 67 deletions
diff --git a/gnu/machine/digital-ocean.scm b/gnu/machine/digital-ocean.scm index 1a91a3a49b..82383a8c7c 100644 --- a/gnu/machine/digital-ocean.scm +++ b/gnu/machine/digital-ocean.scm @@ -26,6 +26,7 @@ #:use-module (guix base32) #:use-module (guix derivations) #:use-module (guix i18n) + #:use-module ((guix diagnostics) #:select (formatted-message)) #:use-module (guix import json) #:use-module (guix monads) #:use-module (guix records) @@ -414,9 +415,7 @@ one procured from https://cloud.digitalocean.com/account/api/tokens."))))))) (let ((config (machine-configuration machine)) (environment (environment-type-name (machine-environment machine)))) (unless (and config (digital-ocean-configuration? config)) - (raise (condition - (&message - (message (format #f (G_ "unsupported machine configuration '~a' + (raise (formatted-message (G_ "unsupported machine configuration '~a' \ for environment of type '~a'") config - environment)))))))) + environment))))) diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index 4148639292..641e871861 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -179,11 +179,9 @@ exist on the machine." (lambda args (system-error-errno args))))) (when (number? errno) - (raise (condition - (&message - (message (format #f (G_ "device '~a' not found: ~a") + (raise (formatted-message (G_ "device '~a' not found: ~a") (file-system-device fs) - (strerror errno))))))))) + (strerror errno)))))) (define (check-labeled-file-system fs) (define remote-exp @@ -196,11 +194,9 @@ exist on the machine." (remote-let ((result remote-exp)) (unless result - (raise (condition - (&message - (message (format #f (G_ "no file system with label '~a'") + (raise (formatted-message (G_ "no file system with label '~a'") (file-system-label->string - (file-system-device fs)))))))))) + (file-system-device fs))))))) (define (check-uuid-file-system fs) (define remote-exp @@ -217,10 +213,8 @@ exist on the machine." (remote-let ((result remote-exp)) (unless result - (raise (condition - (&message - (message (format #f (G_ "no file system with UUID '~a'") - (uuid->string (file-system-device fs)))))))))) + (raise (formatted-message (G_ "no file system with UUID '~a'") + (uuid->string (file-system-device fs))))))) (append (map check-literal-file-system (filter (lambda (fs) @@ -285,12 +279,10 @@ by MACHINE." (system (remote-system (machine-ssh-session machine)))) (when (and (machine-ssh-configuration-build-locally? config) (not (string= system (machine-ssh-configuration-system config)))) - (raise (condition - (&message - (message (format #f (G_ "incorrect target system\ + (raise (formatted-message (G_ "incorrect target system\ ('~a' was given, while the system reports that it is '~a')~%") (machine-ssh-configuration-system config) - system)))))))) + system))))) (define (check-deployment-sanity machine) "Raise a '&message' error condition if it is clear that deploying MACHINE's @@ -402,11 +394,9 @@ environment type of 'managed-host." (when (machine-ssh-configuration-authorize? (machine-configuration machine)) (unless (file-exists? %public-key-file) - (raise (condition - (&message - (message (format #f (G_ "no signing key '~a'. \ + (raise (formatted-message (G_ "no signing key '~a'. \ have you run 'guix archive --generate-key?'") - %public-key-file)))))) + %public-key-file))) (remote-authorize-signing-key (call-with-input-file %public-key-file (lambda (port) (string->canonical-sexp @@ -497,9 +487,7 @@ connection to the host."))) (let ((config (machine-configuration machine)) (environment (environment-type-name (machine-environment machine)))) (unless (and config (machine-ssh-configuration? config)) - (raise (condition - (&message - (message (format #f (G_ "unsupported machine configuration '~a' + (raise (formatted-message (G_ "unsupported machine configuration '~a' for environment of type '~a'") config - environment)))))))) + environment))))) diff --git a/gnu/packages.scm b/gnu/packages.scm index d22c992bb1..4e4282645a 100644 --- a/gnu/packages.scm +++ b/gnu/packages.scm @@ -24,6 +24,7 @@ #:use-module (guix packages) #:use-module (guix ui) #:use-module (guix utils) + #:use-module (guix diagnostics) #:use-module (guix discovery) #:use-module (guix memoization) #:use-module ((guix build utils) @@ -92,9 +93,8 @@ (define (search-patch file-name) "Search the patch FILE-NAME. Raise an error if not found." (or (search-path (%patch-path) file-name) - (raise (condition - (&message (message (format #f (G_ "~a: patch not found") - file-name))))))) + (raise (formatted-message (G_ "~a: patch not found") + file-name)))) (define-syntax-rule (search-patches file-name ...) "Return the list of absolute file names corresponding to each diff --git a/gnu/services.scm b/gnu/services.scm index 6509a9014e..399a432e3f 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -30,7 +30,7 @@ #:use-module (guix describe) #:use-module (guix sets) #:use-module (guix ui) - #:use-module ((guix utils) #:select (source-properties->location)) + #:use-module (guix diagnostics) #:autoload (guix openpgp) (openpgp-format-fingerprint) #:use-module (guix modules) #:use-module (gnu packages base) @@ -242,13 +242,13 @@ TYPE does not have a default value, an error is raised." (if (eq? default &no-default-value) (let ((location (source-properties->location location))) (raise - (condition - (&missing-value-service-error (type type) (location location)) - (&message - (message (format #f (G_ "~a: no value specified \ + (make-compound-condition + (condition + (&missing-value-service-error (type type) (location location))) + (formatted-message (G_ "~a: no value specified \ for service of type '~a'") - (location->string location) - (service-type-name type))))))) + (location->string location) + (service-type-name type))))) (service type default)))) (define-condition-type &service-error &error @@ -725,10 +725,8 @@ and FILE could be \"/usr/bin/env\"." (() #t) (((file _) rest ...) (when (set-contains? seen file) - (raise (condition - (&message - (message (format #f (G_ "duplicate '~a' entry for /etc") - file)))))) + (raise (formatted-message (G_ "duplicate '~a' entry for /etc") + file))) (loop rest (set-insert file seen)))))) ;; Detect duplicates early instead of letting them through, eventually @@ -1000,12 +998,12 @@ TARGET-TYPE; return the root service adjusted accordingly." vlist-null)) (() (raise - (condition (&missing-target-service-error - (service #f) - (target-type target-type)) - (&message - (message (format #f (G_ "service of type '~a' not found") - (service-type-name target-type))))))) + (make-compound-condition + (condition (&missing-target-service-error + (service #f) + (target-type target-type))) + (formatted-message (G_ "service of type '~a' not found") + (service-type-name target-type))))) (x (raise (condition (&ambiguous-target-service-error diff --git a/gnu/system.scm b/gnu/system.scm index 6ae15ab23b..c8ef641695 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -1113,9 +1113,7 @@ TYPE (one of 'iso9660 or 'dce). Return a UUID object." "Variant of 'locale-name->definition' that raises an error upon failure." (match (locale-name->definition name) (#f - (raise (condition - (&message - (message (format #f (G_ "~a: invalid locale name") name)))))) + (raise (formatted-message (G_ "~a: invalid locale name") name))) (def def))) (define (operating-system-locale-directory os) diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index 00f235e6b6..31c50c4e40 100644 --- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm @@ -25,6 +25,7 @@ #:use-module (guix i18n) #:use-module ((guix diagnostics) #:select (source-properties->location + formatted-message &fix-hint &error-location)) #:use-module (gnu services) @@ -132,13 +133,13 @@ DEVICE must be a \"/dev\" file name." ;; "usb_storage"), not file names (e.g., "usb-storage.ko"). This is ;; OK because we have machinery that accepts both the hyphen and the ;; underscore version. - (raise (condition - (&message - (message (format #f (G_ "you may need these modules \ + (raise (make-compound-condition + (formatted-message (G_ "you may need these modules \ in the initrd for ~a:~{ ~a~}") - device missing))) - (&fix-hint - (hint (format #f (G_ "Try adding them to the + device missing) + (condition + (&fix-hint + (hint (format #f (G_ "Try adding them to the @code{initrd-modules} field of your @code{operating-system} declaration, along these lines: @@ -151,9 +152,10 @@ these lines: If you think this diagnostic is inaccurate, use the @option{--skip-checks} option of @command{guix system}.\n") - missing))) - (&error-location - (location (source-properties->location location))))))) + missing)))) + (condition + (&error-location + (location (source-properties->location location)))))))) ;;; @@ -215,13 +217,13 @@ option of @command{guix system}.\n") (if (uuid? source) (match (find-partition-by-luks-uuid (uuid-bytevector source)) (#f - (raise (condition - (&message - (message (format #f (G_ "no LUKS partition with UUID '~a'") - (uuid->string source)))) - (&error-location - (location (source-properties->location - (mapped-device-location md))))))) + (raise (make-compound-condition + (formatted-message (G_ "no LUKS partition with UUID '~a'") + (uuid->string source)) + (condition + (&error-location + (location (source-properties->location + (mapped-device-location md)))))))) ((? string? device) (check-device-initrd-modules device initrd-modules location))) (check-device-initrd-modules source initrd-modules location))))) |