Functional vs Object Oriented Approach for UI codes
Object oriented doesn't really makes sense to me here. That FormattedError class doesn't even represent anything, just transforming error constructor parameter to another class. 

Also you are calling constructor, that then returns instance of something else? I don't know javascript that much so maybe it's some unknown construct to me, but that looks like something terribly wrong.

Edit:

I see no relevance to code being UI code or not.