[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#60802] [PATCH v2 1/2] platforms: Raise an exception when no suitabl
From: |
Ludovic Courtès |
Subject: |
[bug#60802] [PATCH v2 1/2] platforms: Raise an exception when no suitable platform is found. |
Date: |
Sat, 14 Jan 2023 15:34:32 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Hi,
Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
> This was motivated by #60786, which produced a cryptic, hard to understand
> backtrace.
>
> * guix/platform.scm (&platform-not-found-error): New exception type.
> (make-platform-not-found-error): New exception constructor.
> (platform-not-found-error?): New predicate.
> (false-if-platform-not-found): New syntax.
> (lookup-platform-by-system): Raise an exception when no platform is found.
> Update documentation.
> (lookup-platform-by-target): Likewise.
> (lookup-platform-by-target-or-system): Likewise, and guard lookup calls with
> false-if-platform-not-found.
Sounds like a good idea!
> +++ b/gnu/packages/bootstrap.scm
> @@ -315,7 +315,7 @@ (define* (glibc-dynamic-linker
> (%current-system))))
> "Return the name of Glibc's dynamic linker for SYSTEM."
> ;; See the 'SYSDEP_KNOWN_INTERPRETER_NAMES' cpp macro in libc.
> - (let ((platform (lookup-platform-by-system system)))
> + (let ((platform (false-if-exception (lookup-platform-by-system system))))
Maybe we don’t need to protect here, because it’s a
> +++ b/guix/platform.scm
> @@ -21,6 +21,7 @@ (define-module (guix platform)
> #:use-module (guix memoization)
> #:use-module (guix records)
> #:use-module (guix ui)
> + #:use-module (ice-9 exceptions)
So far the we use (srfi srfi-35) exclusively to define condition types;
I think we should do the same here, for consistency.
> + &platform-not-found-error
> + make-platform-not-found-error
The constructor doesn’t need to be exposed.
> +;;;
> +;;; Exceptions.
> +;;;
> +(define-exception-type &platform-not-found-error &error
> + make-platform-not-found-error platform-not-found-error?)
So this would become (define-condition-type …).
Otherwise LGTM, thanks!
Ludo’.