Ensure all Error objects contain a stack prop #3653

This commit is contained in:
Lovell Fuller
2023-10-11 14:59:21 +01:00
parent 68fa84ef6f
commit 47e76c9981
7 changed files with 135 additions and 47 deletions

View File

@@ -690,11 +690,25 @@ describe('Image Stats', function () {
it('File input with corrupt header fails gracefully', function (done) {
sharp(fixtures.inputJpgWithCorruptHeader)
.stats(function (err) {
assert.strictEqual(true, !!err);
assert(err.message.includes('Input file has corrupt header'));
assert(err.stack.includes('at Sharp.stats'));
assert(err.stack.includes(__filename));
done();
});
});
it('Stream input with corrupt header fails gracefully', function (done) {
fs.createReadStream(fixtures.inputJpgWithCorruptHeader).pipe(
sharp()
.stats(function (err) {
assert(err.message.includes('Input buffer has corrupt header'));
assert(err.stack.includes('at Sharp.stats'));
assert(err.stack.includes(__filename));
done();
})
);
});
it('File input with corrupt header fails gracefully, Promise out', function () {
return sharp(fixtures.inputJpgWithCorruptHeader)
.stats().then(function (stats) {