Skip to content

Improve Empty response handling in Either and Domain implementations#2

Open
LuisAlvarez5 wants to merge 4 commits intolevel-two:mainfrom
LuisAlvarez5:main
Open

Improve Empty response handling in Either and Domain implementations#2
LuisAlvarez5 wants to merge 4 commits intolevel-two:mainfrom
LuisAlvarez5:main

Conversation

@LuisAlvarez5
Copy link

Improve Empty response handling in Either and Domain implementations

This commit enhances the way to handle empty responses, particularly for Either types.

Key Changes:

  • Implement type-safe Either response checking using EitherCheckable protocol
  • Replace string-based type checking with Swift's native type system
  • Add safe empty JSON data handling without force unwrapping
  • Unify empty response handling for both Empty and Either<Empty, ErrorResponse> types
  • Improve decoder implementation to handle empty responses consistently

Technical Details:

  • Add EitherCheckable protocol for type-safe Either response type inspection
  • Implement static responseType property to access generic type information
  • Add safe initialization for empty JSON data
  • Consolidate empty response handling logic in Domain.perform

}

private extension Domain {
static let emptyJsonData: Data = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static let emptyJsonData = Data("{}".utf8)

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.

2 participants