Skip to content

Commit

Permalink
[bugfix] Avoid 400 error when pkg not found
Browse files Browse the repository at this point in the history
Previously, a request for a package like packages/foo.html or packages/monex.html?eXist-db-min-version=1.0.0 would return XQuery errors. This provides a proper 404 error and a human-readable error message for each condition.
  • Loading branch information
joewiz committed Feb 20, 2019
1 parent ecf166a commit 762a35f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion modules/app.xql
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ declare function app:view-package($node as node(), $model as map(*), $mode as xs
let $package := $app-versions[@path eq $compatible-xar]
let $show-details := true()
return
app:package-to-list-item($package, $show-details)
if (exists($package)) then
app:package-to-list-item($package, $show-details)
else
(
response:set-status-code(404),
if (exists($app)) then
<li class="package text-warning">Package {$abbrev} requires a newer version of eXist.</li>
else
<li class="package text-warning">No package {$abbrev} is available.</li>
)
};

declare function app:package-to-list-item($app as element(app), $show-details as xs:boolean) {
Expand Down

0 comments on commit 762a35f

Please sign in to comment.