Refactor serializer errors

Reduce indentation and increase linearity to improve readability.