Move code for calling editor into its own function; raise errors