Catching JSON parse errors

Adding a try catch to prevent crash on JSON parsing exception + adding
a error callback to handle erroneous message