Add generic error handling

Just in case a factory reset happens to fail.