Reorder object definition for error data
Refactor emit action into its own method