KAA-217: Get rid of error handling in the common serializing function to reduce code size.