Skip to content

Commit 69302a2

Browse files
committed
Now attaching error listener to connection
1 parent c189b8f commit 69302a2

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/actions/insert.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ function init(cfg) {
1212
return co(function* gen() {
1313
console.log('Connecting to the database uri=%s', conString);
1414
const connection = new cosql.Connection(conString);
15+
// Always attach an error listener
16+
connection.on('error', (err) => this.emit('error', err));
1517
let sql = cfg.query;
1618
yield connection.connect();
1719
console.log('Preparing query=%s', sql);
@@ -46,7 +48,7 @@ function init(cfg) {
4648
console.log('Resulting SQL=%s', sql);
4749
yield pstmt.prepare(sql);
4850
console.log('Preparing statement created');
49-
});
51+
}.bind(this));
5052
}
5153

5254
/**

lib/actions/select.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ function init(cfg) {
1616
return co(function* gen() {
1717
console.log('Connecting to the database uri=%s', conString);
1818
connection = new cosql.Connection(conString);
19+
connection.on('error', (err) => this.emit('error', err));
1920
yield connection.connect();
20-
});
21+
}.bind(this));
2122
}
2223
/**
2324
* This method will be called from elastic.io platform providing following data

0 commit comments

Comments
 (0)