DRY up some exception handling; communicate with js on a different
thread