Skip to content

Commit

Permalink
fix some http 500 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Jan 4, 2025
1 parent 59a78d1 commit 34caa26
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ function mongo_package_stream(pkg, universe){
var query = {Package: pkg, _user: universe, _type: 'src'};
return packages.findOne(query, {sort: {'_id': -1}}).then(function(x){
if(!x)
throw `Package ${pkg} not found in ${universe}`;
throw createError(404, `Package ${pkg} not found in ${universe}`);
return bucket.openDownloadStream(x._fileid);
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import tar from 'tar-stream';
import gunzip from 'gunzip-maybe';
import {load as cheerio_load} from 'cheerio';
import hljs from 'highlight.js';
import createError from 'http-errors';

export const pkgfields = {_id: 1, _type:1, _fileid:1, _dependencies: 1, Filesize: '$_filesize', Distro: '$_distro',
SHA256: '$_sha256', Package: 1, Version: 1, Depends: 1, Suggests: 1, License: 1,
Expand Down Expand Up @@ -170,5 +171,5 @@ export function match_macos_arch(platform){
if(platform.match("x86_64")){
return {$not : /aarch64/};
}
throw `Unknown platform: ${platform}`;
throw createError(404, `Unsupported MacOS version: ${platform}`);
}

0 comments on commit 34caa26

Please sign in to comment.