add error handling code in a bunch of places to start producing better linting and error feedback