Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass errors as Error instances rather than strings. #106

Merged
merged 1 commit into from Oct 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/metadata.cc
Expand Up @@ -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>();
Expand Down
7 changes: 7 additions & 0 deletions test/unit/metadata.js
Expand Up @@ -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();
});
});
});