Skip to content

Adopt typed throws for JSONError#31

Merged
muukii merged 1 commit into
mainfrom
feature/typed-throws
Jul 14, 2025
Merged

Adopt typed throws for JSONError#31
muukii merged 1 commit into
mainfrom
feature/typed-throws

Conversation

@muukii

@muukii muukii commented Jul 14, 2025

Copy link
Copy Markdown
Collaborator

Summary

This PR updates the JAYSON library to adopt Swift's typed throws feature, making it explicit that methods can only throw JSONError. This provides better type safety and clearer API contracts.

Changes

  • ✅ Updated all throwing initializers to use throws(JSONError)
  • ✅ Updated all throwing methods to use throws(JSONError)
  • ✅ Updated Decoder to use typed throws for consistency
  • ✅ Simplified error handling by removing redundant catch blocks
  • ✅ Fixed reduce usage that doesn't support typed throws yet

Testing

  • All existing tests pass without modification
  • Build succeeds with no warnings
  • Backward compatibility is maintained

Benefits

  1. Type Safety: Callers know exactly what error type to expect
  2. Better Documentation: The API contract is clearer
  3. Simplified Error Handling: No need to catch and rethrow JSONError
  4. Future-proof: Aligns with Swift's direction for error handling

🤖 Generated with Claude Code

- Update Decoder to use typed throws(JSONError)
- Convert all JSON getter methods to typed throws
- Update error handling in JSON initialization and data methods
- Simplify error propagation by removing redundant catch blocks

This change leverages Swift's typed throws feature to provide
more precise error handling for JSON operations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@muukii muukii merged commit 5ed1d95 into main Jul 14, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant