Print error if occurred in WriteMsg
Merge pull request #779 from francoishill/patch-17

Print error if occurred in WriteMsg