Update errors across lib/image and lib/request

- swap common.errors for @tryghost/errors
- doing this in batches across small parts of the codebase to reduce disruption
This commit is contained in:
Hannah Wolfe 2020-03-25 10:25:25 +00:00
parent 64129a5cfd
commit b8ab3414ff
2 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,5 @@
const Promise = require('bluebird');
const common = require('../common');
const errors = require('@tryghost/errors');
const fs = require('fs-extra');
/**
@ -46,14 +46,14 @@ const makeSafe = fn => (...args) => {
try {
require('sharp');
} catch (err) {
return Promise.reject(new common.errors.InternalServerError({
return Promise.reject(new errors.InternalServerError({
message: 'Sharp wasn\'t installed',
code: 'SHARP_INSTALLATION',
err: err
}));
}
return fn(...args).catch((err) => {
throw new common.errors.InternalServerError({
throw new errors.InternalServerError({
message: 'Unable to manipulate image.',
err: err,
code: 'IMAGE_PROCESSING'

View File

@ -1,7 +1,7 @@
const should = require('should');
const sinon = require('sinon');
const fs = require('fs-extra');
const common = require('../../../../server/lib/common');
const errors = require('@tryghost/errors');
const manipulator = require('../../../../server/lib/image/manipulator');
const testUtils = require('../../../utils');
@ -110,7 +110,7 @@ describe('lib/image: manipulator', function () {
'1'.should.eql(1, 'Expected to fail');
})
.catch((err) => {
(err instanceof common.errors.InternalServerError).should.be.true;
(err instanceof errors.InternalServerError).should.be.true;
err.code.should.eql('IMAGE_PROCESSING');
});
});
@ -127,7 +127,7 @@ describe('lib/image: manipulator', function () {
'1'.should.eql(1, 'Expected to fail');
})
.catch((err) => {
(err instanceof common.errors.InternalServerError).should.be.true();
(err instanceof errors.InternalServerError).should.be.true();
err.code.should.eql('SHARP_INSTALLATION');
});
});