Refactored InvalidError handling into a serializer concern.
Merge pull request #2392 from ahacking/serialization-for-invalid-error

Refactored InvalidError handling into a serializer concern.