Skip to content

Commit

Permalink
Merge pull request #33 from cybersam/master
Browse files Browse the repository at this point in the history
 Make SQSError properly inherit from Error, and also have a stack trace
  • Loading branch information
Nick Spragg committed May 12, 2016
2 parents 1376852 + 1ef3fb9 commit 9e60a90
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ var requiredOptions = [
* Construct a new SQSError
*/
function SQSError(message) {
this.name = 'SQSError';
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = (message || '');
}
SQSError.prototype = Error.prototype;
util.inherits(SQSError, Error);

function validate(options) {
requiredOptions.forEach(function (option) {
Expand Down Expand Up @@ -151,7 +152,7 @@ Consumer.prototype._processMessage = function (message, cb) {
}
], function (err) {
if (err) {
if (err.name === 'SQSError') {
if (err.name === SQSError.name) {
consumer.emit('error', err);
} else {
consumer.emit('processing_error', err);
Expand Down

0 comments on commit 9e60a90

Please sign in to comment.