Skip to content

Error propagation UI#4

Open
estebanuribe wants to merge 6 commits intopull-refreshfrom
error-propagation-ui
Open

Error propagation UI#4
estebanuribe wants to merge 6 commits intopull-refreshfrom
error-propagation-ui

Conversation

@estebanuribe
Copy link
Copy Markdown
Collaborator

Propagate errors from Rust to Swift via GiphRSError

/**
* Converts a GiphRsError to a standard Kotlin Exception
*/
fun GiphRsError.toException(): Exception {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This gets translated by UniFFI to GiphRsException which is an Exception

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Is this redundant then? Should I remove this function?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fix this, should be GiphRSException now.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

See:

fun GiphRsException.toException(): Exception {
return when (this) {
is GiphRsException.NetworkException ->
IOException("Network Error: ${this.message}")
is GiphRsException.ParseException ->
IllegalStateException("Parse Error: ${this.message}")
is GiphRsException.ApiException ->
Exception("API Error: ${this.message}")
is GiphRsException.Unknown ->
Exception("Unknown Error: ${this.message}")
}

@@ -53,7 +54,7 @@ impl RustViewModel {
}

pub fn has_error(&self) -> bool {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This should follow the pattern of having an accessor and a polling function for changes it should be updated to return Option<GiphRsError>

However, this introduces an issue as a stream's terminal state is indicated by a None value. We could get around it by adding a GiphRsError.None enum value

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I went ahead and created GiphRsErrorState to avoid having a None state in GiphRsError which based on research appears to be an anti-pattern. Updated iOS and Android with the new enum, was able to build on both now!!!!

Screen_recording_20260422_175329.webm

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@estebanuribe estebanuribe requested a review from saik0 April 23, 2026 00:56
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