Replace panics with errors and a call to os.Exit