Updated "getFile" to send a 404 for ENOENT errors

getFile sends a 500 error response when the requested file cannot be
found, but the status code probably should be 404. This change sets
the status of the error to 404 when the error code is "ENOENT".
This commit is contained in:
Cory Gottschalk 2018-04-24 13:52:45 -07:00
parent 537e1158d4
commit 970ecc7901
1 changed files with 4 additions and 0 deletions

View File

@ -210,6 +210,10 @@ StorageService.prototype.getFiles = function(container, options, cb) {
*/
StorageService.prototype.getFile = function(container, file, cb) {
return this.client.getFile(container, file, function(err, f) {
if (err && err.code === 'ENOENT') {
err.statusCode = err.status = 404;
return cb(err);
}
return cb(err, map(f));
});
};