Add support for serializing error replies
Add test for serializing error reply