Implemented message error handling. Closes #1914.