change error handling to display error to console before throwing error