{"record":{"id":"3e635a90d5f90f1e","repo":"affaan-m/ECC","slug":"failed-to-parse-data-data","errorCode":null,"errorMessage":"Failed to parse data: {data}","messagePattern":"Failed to parse data: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/python-patterns/SKILL.md","lineNumber":172,"sourceCode":"\n# Bad: Bare except\ndef load_config(path: str) -> Config:\n    try:\n        with open(path) as f:\n            return Config.from_json(f.read())\n    except:\n        return None  # Silent failure!\n```\n\n### Exception Chaining\n\n```python\ndef process_data(data: str) -> Result:\n    try:\n        parsed = json.loads(data)\n    except json.JSONDecodeError as e:\n        # Chain exceptions to preserve the traceback\n        raise ValueError(f\"Failed to parse data: {data}\") from e\n```\n\n### Custom Exception Hierarchy\n\n```python\nclass AppError(Exception):\n    \"\"\"Base exception for all application errors.\"\"\"\n    pass\n\nclass ValidationError(AppError):\n    \"\"\"Raised when input validation fails.\"\"\"\n    pass\n\nclass NotFoundError(AppError):\n    \"\"\"Raised when a requested resource is not found.\"\"\"\n    pass\n\n# Usage","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/affaan-m/ECC/blob/d8409a4b0813771235555e32e3d8046a73988bfa/skills/python-patterns/SKILL.md#L154-L190","documentation":"Illustrative exception-chaining example from the python-patterns skill: process_data's json.loads raised JSONDecodeError and it is re-raised as ValueError containing the raw data, with the original preserved via `from e`. The malformed data string is the input at fault.","triggerScenarios":"Thrown at skills/python-patterns/SKILL.md:172 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include the decode error's position instead of echoing the whole payload","Truncate long data in the message to avoid log bloat","Distinguish malformed input from other ValueErrors with a dedicated exception type"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d8409a4b0813771235555e32e3d8046a73988bfa","analyzedAt":"2026-08-26T12:15:34.022Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}