mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Merge pull request #106 from papandreou/errorInstances
Pass errors as Error instances rather than strings.
This commit is contained in:
commit
4a4dd7f987
@ -87,7 +87,7 @@ class MetadataWorker : public NanAsyncWorker {
|
||||
Handle<Value> argv[2] = { NanNull(), NanNull() };
|
||||
if (!baton->err.empty()) {
|
||||
// Error
|
||||
argv[0] = NanNew<String>(baton->err.data(), baton->err.size());
|
||||
argv[0] = Exception::Error(NanNew<String>(baton->err.data(), baton->err.size()));
|
||||
} else {
|
||||
// Metadata Object
|
||||
Local<Object> info = NanNew<Object>();
|
||||
|
@ -185,4 +185,11 @@ describe('Image metadata', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Report an invalid image as an error', function(done) {
|
||||
sharp(new Buffer([0x1, 0x2, 0x3, 0x4])).metadata(function (err, metadata) {
|
||||
assert.ok(err);
|
||||
assert.ok(err instanceof Error);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user