copy error handling from bootstrap3