Refactor stylesheet error handling