general error handling to stop people breaking everything horribly