Skip to content

Commit

Permalink
error logging for native errors
Browse files Browse the repository at this point in the history
  • Loading branch information
krystianity committed May 31, 2018
1 parent c7a6310 commit cf4fce7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# sinek CHANGELOG

## 2018-05-31, Version 6.16.0

* updated NConsumer and NProducer to debug and concat errors of require of native lib

## 2018-03-27, Version 6.15.1

* node-rdkafka has seg fault bugs in 2.3.1 -> falling back to 2.2.3
Expand Down
17 changes: 9 additions & 8 deletions lib/librdkafka/NConsumer.js
Expand Up @@ -53,14 +53,6 @@ class NConsumer extends EventEmitter {
constructor(topics, config = { options: {} }) {
super();

try {
if(!BlizzKafka){
BlizzKafka = require("node-rdkafka");
}
} catch(error){
throw new Error("You have to install node-rdkafka to use NConsumer.");
}

if(!config){
throw new Error("You are missing a config object.");
}
Expand All @@ -69,6 +61,15 @@ class NConsumer extends EventEmitter {
config.logger = DEFAULT_LOGGER;
}

try {
if(!BlizzKafka){
BlizzKafka = require("node-rdkafka");
}
} catch(error){
config.logger.error(error);
throw new Error("You have to install node-rdkafka to use NConsumer. " + error.message);
}

if(!config.options){
config.options = {};
}
Expand Down
17 changes: 9 additions & 8 deletions lib/librdkafka/NProducer.js
Expand Up @@ -65,14 +65,6 @@ class NProducer extends EventEmitter {
constructor(config, _, defaultPartitionCount = 1) {
super();

try {
if (!BlizzKafka) {
BlizzKafka = require("node-rdkafka");
}
} catch (error) {
throw new Error("You have to install node-rdkafka to use NProducer.");
}

if (!config) {
throw new Error("You are missing a config object.");
}
Expand All @@ -81,6 +73,15 @@ class NProducer extends EventEmitter {
config.logger = DEFAULT_LOGGER;
}

try {
if (!BlizzKafka) {
BlizzKafka = require("node-rdkafka");
}
} catch (error) {
config.logger.error(error);
throw new Error("You have to install node-rdkafka to use NProducer. " + error.message);
}

if (!config.options) {
config.options = {};
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "sinek",
"version": "6.15.2",
"version": "6.16.0",
"description": "Node.js kafka client, consumer, producer polite out of the box",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit cf4fce7

Please sign in to comment.