mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 00:54:50 +03:00
🎨 Switched to 404 error in image size utility (#8862)
refs #8850 - This reduces the amount of noise from the image size utility.
This commit is contained in:
parent
f554523d23
commit
147ec91162
@ -1,6 +1,7 @@
|
||||
var Promise = require('bluebird'),
|
||||
size = require('./image-size-from-url'),
|
||||
logging = require('../logging'),
|
||||
errors = require('../errors'),
|
||||
getImageSizeFromUrl = size.getImageSizeFromUrl,
|
||||
imageSizeCache = {};
|
||||
|
||||
@ -23,6 +24,9 @@ function getCachedImageSizeFromUrl(url) {
|
||||
imageSizeCache[url] = res;
|
||||
|
||||
return Promise.resolve(imageSizeCache[url]);
|
||||
}).catch(errors.NotFoundError, function () {
|
||||
// in case of error we just attach the url
|
||||
return Promise.resolve(imageSizeCache[url] = url);
|
||||
}).catch(function (err) {
|
||||
logging.error(err);
|
||||
|
||||
|
@ -79,9 +79,16 @@ module.exports.getImageSizeFromUrl = function getImageSizeFromUrl(imagePath) {
|
||||
context: imagePath
|
||||
}));
|
||||
}
|
||||
} else if (res.statusCode === 404) {
|
||||
return reject(new errors.NotFoundError({
|
||||
message: 'Image not found.',
|
||||
code: 'IMAGE_SIZE',
|
||||
statusCode: res.statusCode,
|
||||
context: imagePath
|
||||
}));
|
||||
} else {
|
||||
return reject(new errors.InternalServerError({
|
||||
message: res.statusCode === 404 ? 'Image not found.' : 'Unknown Request error.',
|
||||
message: 'Unknown Request error.',
|
||||
code: 'IMAGE_SIZE',
|
||||
statusCode: res.statusCode,
|
||||
context: imagePath
|
||||
|
Loading…
Reference in New Issue
Block a user