Javascript snippet for collecting errors from your front-end code