mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Ensure resize error from C++ is wrapped
Thanks to @papandreou
This commit is contained in:
parent
3e1be7a33a
commit
97fc2a2a3a
@ -590,6 +590,7 @@ This module would never have been possible without the help and code contributio
|
|||||||
* [Julian Walker](https://github.com/julianwa)
|
* [Julian Walker](https://github.com/julianwa)
|
||||||
* [Amit Pitaru](https://github.com/apitaru)
|
* [Amit Pitaru](https://github.com/apitaru)
|
||||||
* [Brandon Aaron](https://github.com/brandonaaron)
|
* [Brandon Aaron](https://github.com/brandonaaron)
|
||||||
|
* [Andreas Lind](https://github.com/papandreou)
|
||||||
|
|
||||||
Thank you!
|
Thank you!
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
"Daniel Gasienica <daniel@gasienica.ch>",
|
"Daniel Gasienica <daniel@gasienica.ch>",
|
||||||
"Julian Walker <julian@fiftythree.com>",
|
"Julian Walker <julian@fiftythree.com>",
|
||||||
"Amit Pitaru <pitaru.amit@gmail.com>",
|
"Amit Pitaru <pitaru.amit@gmail.com>",
|
||||||
"Brandon Aaron <hello.brandon@aaron.sh>"
|
"Brandon Aaron <hello.brandon@aaron.sh>",
|
||||||
|
"Andreas Lind <andreas@one.com>"
|
||||||
],
|
],
|
||||||
"description": "High performance Node.js module to resize JPEG, PNG and WebP images using the libvips library",
|
"description": "High performance Node.js module to resize JPEG, PNG and WebP images using the libvips library",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -45,7 +46,7 @@
|
|||||||
"nan": "^1.3.0"
|
"nan": "^1.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"mocha": "^1.21.5",
|
"mocha": "^2.0.0",
|
||||||
"mocha-jshint": "^0.0.9",
|
"mocha-jshint": "^0.0.9",
|
||||||
"istanbul": "^0.3.2",
|
"istanbul": "^0.3.2",
|
||||||
"coveralls": "^2.11.2"
|
"coveralls": "^2.11.2"
|
||||||
|
@ -586,7 +586,7 @@ class ResizeWorker : public NanAsyncWorker {
|
|||||||
Handle<Value> argv[3] = { NanNull(), NanNull(), NanNull() };
|
Handle<Value> argv[3] = { NanNull(), NanNull(), NanNull() };
|
||||||
if (!baton->err.empty()) {
|
if (!baton->err.empty()) {
|
||||||
// Error
|
// Error
|
||||||
argv[0] = NanNew<String>(baton->err.data(), baton->err.size());
|
argv[0] = Exception::Error(NanNew<String>(baton->err.data(), baton->err.size()));
|
||||||
} else {
|
} else {
|
||||||
int width = baton->width;
|
int width = baton->width;
|
||||||
int height = baton->height;
|
int height = baton->height;
|
||||||
|
@ -198,6 +198,15 @@ describe('Input/output', function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Fail when input is invalid Buffer', function(done) {
|
||||||
|
sharp(new Buffer([0x1, 0x2, 0x3, 0x4]))
|
||||||
|
.toBuffer(function (err) {
|
||||||
|
assert.ok(err);
|
||||||
|
assert.ok(err instanceof Error);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Promises/A+', function(done) {
|
it('Promises/A+', function(done) {
|
||||||
sharp(fixtures.inputJpg).resize(320, 240).toBuffer().then(function(data) {
|
sharp(fixtures.inputJpg).resize(320, 240).toBuffer().then(function(data) {
|
||||||
sharp(data).toBuffer(function(err, data, info) {
|
sharp(data).toBuffer(function(err, data, info) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user