change all error logging to throw errors