Not really getting what you would like here (sorry).  Do you want error to actually use alert to render?  I split error out so you wouldn't have to switch alert to use an array.