mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +03:00
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:
parent
64129a5cfd
commit
b8ab3414ff
@ -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'
|
||||
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user