Description
The documentation example in docs/docs/exosphere/index.md uses a bare except: clause when parsing JSON, which is not a best practice and sets a poor example for users.
Current Code
try:
data = json.loads(self.inputs.data)
except:
return self.Outputs(
result="",
status="error: invalid json"
)
Suggested Fix
try:
data = json.loads(self.inputs.data)
except json.JSONDecodeError:
return self.Outputs(
result="",
status="error: invalid json"
)
Why This Matters
- Bare except clauses catch all exceptions, potentially hiding bugs
- Documentation should demonstrate best practices
- Specific exception handling makes code more maintainable and debuggable
References
Requested by: @nk-ag