fojas / cleverbot-node

Cleverbot client in node.js
MIT License
62 stars 33 forks source link

Error handling #35

Closed danielriddell21 closed 7 years ago

danielriddell21 commented 7 years ago

At the comment I'm using the try and catch method. But it still errors and crashes. It's a JSON error... I'm guessing this is fixed in the newest release

fojas commented 7 years ago

I'm not sure I understad the issue. Do you have examples of what you are doing and what is going wrong?

ghost commented 7 years ago

The process exits when there is an error while trying to parse the JSON response. Putting cleverbot.write inside a try-catch block doesn't catch the error.

fojas commented 7 years ago

I added an errorCallback argument to the write function. I don't want to make assumptions about how users want to handle errors. If an error occurs, the callback is called and the write function just returns without continuing. I hope that is enough.

Thanks!