GNU bug report logs -
#49196
[PATCH] "guix import go" Improve error handling
Previous Next
Reported by: Sarah Morgensen <iskarian <at> mgsn.dev>
Date: Wed, 23 Jun 2021 20:50:02 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hi,
On Sun, 27 Jun 2021 at 06:46, Sarah Morgensen <iskarian <at> 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
This bug report was last modified 3 years and 262 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.