guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#49196] [PATCH] import: utils: 'recursive-import' skips unfound pack


From: zimoun
Subject: [bug#49196] [PATCH] import: utils: 'recursive-import' skips unfound packages
Date: Mon, 28 Jun 2021 13:42:26 +0200

Hi,

On Sun, 27 Jun 2021 at 06:46, Sarah Morgensen <iskarian@mgsn.dev> wrote:

> A catch-all is fine, but we should at least report the actual error,
> even if it's not pretty:
>
>     (warning (G_ "Failed to import package ~s.~%  reason: ~s")
>                   package-name (exception-args c))

Well, why not, even if I am not convinced the reason is meaningful
because it is mostly an incorrect parsing which returns:

   reason: ("match" "no matching pattern" #f).

and I think it is better to display the complete 'args' instead of
extract the URL (package-name) from 'args'.

> However, if we want to move in the direction of proper error handling
> like guix/packages.scm and guix/ui.scm, we can do something like...

Thanks for the idea.  As explained patch#45984 [1], all the UI
messages must be in guix/scripts/import and not in guix/import and
therefore, indeed, error reporting needs to be unified between all the
importers and raised accordingly; that's what we are working on with
jeko (Jérémy Korwin-Zmijowski) as pair-programming exercise. :-)

1: <http://issues.guix.gnu.org/issue/45984>

> --8<---------------cut here---------------start------------->8---
> (define (report-import-error package-name error)
>   (cond
>    ((http-get-error? error)
>     [...]
>    (else
>     [...]))))
>
> (define* (go-module->guix-package* module-path
>                                    #:key (on-error report-import-error)
>                                    #:allow-other-keys #:rest args)
>   (with-exception-handler
>       (lambda (error)
>         (on-error module-path error)
>         (values #f '()))
>     (lambda () (apply go-module->guix-package module-path args))
>     #:unwind? #t))
>
> (define* (go-module-recursive-import package-name
>                                      #:key (goproxy 
> "https://proxy.golang.org";)
>                                      version
>                                      pin-versions?)
>   (recursive-import
>    package-name
>    #:repo->guix-package
>    (memoize
>     (lambda* (name #:key version repo)
>       (go-module->guix-package* name #:goproxy goproxy
>                                 #:version version
>                                 #:pin-versions? pin-versions?)))
>    #:guix-name go-module->guix-package-name
>    #:version version))
> --8<---------------cut here---------------end--------------->8---
>
> Looks like I got a little carried away :) But breaking out the error
> reporting gives us the future option of "plugging in" other error
> reporting strategies, such as collating them and returning them
> alongside a programmatic recursive import, or being able to provide a
> list of packages which failed to import at the end. This will be much
> more useful once we have a proper set of import error conditions.

Back to the initial patch, I think it is better to simply fix with the
minor improvements of v3 your proposed and let this last proposal for
#45984; feel free to comment there. ;-)

Cheers,
simon





reply via email to

[Prev in Thread] Current Thread [Next in Thread]