Skip to content

Commit

Permalink
Attach rawMessage property to error on execute() (jbmusso#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
princjef authored and jbmusso committed Feb 19, 2018
1 parent 0a080bd commit 8f1a7b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions gremlin-client/src/GremlinClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ class GremlinClient extends EventEmitter {
break;
default:
delete this.commands[requestId];
messageStream.emit(
'error',
new Error(statusMessage + ' (Error ' + statusCode + ')'),
);
const error = new Error(statusMessage + ' (Error ' + statusCode + ')');
error.rawMessage = rawMessage;
messageStream.emit('error', error);
break;
}
}
Expand Down
4 changes: 3 additions & 1 deletion gremlin-client/src/execute.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require('chai').should();
import { assert } from 'chai';
import { assert, expect } from 'chai';
import gremlin, { statics } from './';

import { get } from 'lodash';
Expand Down Expand Up @@ -110,6 +110,8 @@ describe('.execute()', function() {

client.execute(script, function(err, result) {
(err === null).should.be.false;
expect(err.rawMessage).to.have.property('status');
expect(err.rawMessage).to.have.property('requestId');
done();
});
});
Expand Down

0 comments on commit 8f1a7b3

Please sign in to comment.