Handle package versions not being found

This commit is contained in:
Christopher Baines 2025-11-13 12:45:50 +00:00
parent 571ed55c9f
commit 9a03cdff18
2 changed files with 33 additions and 22 deletions

View file

@ -993,28 +993,34 @@
'(application/json text/html) '(application/json text/html)
mime-types) mime-types)
((application/json) ((application/json)
(render-json (if (null? metadata)
`((name . ,name) (render-json
(version . ,version) `((name . ,name)
,@(match metadata (version . ,version)
(((synopsis synopsis-locale description description-locale home-page file line column-number (error . "package not found"))
licenses)) #:code 404)
`((synopsis . ,(texinfo->variants-alist synopsis synopsis-locale)) (render-json
(description . ,(texinfo->variants-alist description description-locale)) `((name . ,name)
(location (version . ,version)
. ((file . ,file) ,@(match metadata
(line . ,line) (((synopsis synopsis-locale description description-locale home-page file line column-number
(column . ,column-number))) licenses))
(home-page . ,home-page)))) `((synopsis . ,(texinfo->variants-alist synopsis synopsis-locale))
(derivations . ,(list->vector (description . ,(texinfo->variants-alist description description-locale))
(map (match-lambda (location
((system target file-name status outputs) . ((file . ,file)
`((system . ,system) (line . ,line)
(target . ,target) (column . ,column-number)))
(derivation . ,file-name) (home-page . ,home-page))))
(outputs . ,(list->vector outputs))))) (derivations . ,(list->vector
derivations)))) (map (match-lambda
#:extra-headers http-headers-for-unchanging-content)) ((system target file-name status outputs)
`((system . ,system)
(target . ,target)
(derivation . ,file-name)
(outputs . ,(list->vector outputs)))))
derivations))))
#:extra-headers http-headers-for-unchanging-content)))
(else (else
(render-html (render-html
#:sxml (view-revision-package-and-version commit-hash #:sxml (view-revision-package-and-version commit-hash
@ -1030,6 +1036,9 @@
#:header-link header-link #:header-link header-link
#:version-history-link #:version-history-link
version-history-link) version-history-link)
#:code (if (null? metadata)
404
200)
#:extra-headers http-headers-for-unchanging-content))))) #:extra-headers http-headers-for-unchanging-content)))))
(define* (render-revision-package-derivations mime-types (define* (render-revision-package-derivations mime-types

View file

@ -243,6 +243,8 @@
(div (div
(@ (class "col-sm-12")) (@ (class "col-sm-12"))
,(match package-metadata ,(match package-metadata
(()
"Package not found at this version")
(((synopsis synopsis-locale description description-locale home-page file line column-number (((synopsis synopsis-locale description description-locale home-page file line column-number
licenses)) licenses))
`(dl `(dl