Wrap exception-throwing calls into promise functions