Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return message string from model panic handler to be displayed in UI … #1534

Merged

Conversation

mxdamien
Copy link
Contributor

@mxdamien mxdamien commented Jan 24, 2023

…status

closes #1519

Copy link
Owner

@hannobraun hannobraun left a comment

Choose a reason for hiding this comment

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

Thank for you for this pull request, @mxdamien!

I think this is a good start. The main cause of panics, the user-written model code, is taken care of. However, there are some problems around the periphery. I've left some comments with my thoughts. Please let me know what you think!

Also, and this is more a note to myself, here's what a todo!() in model code looks like, as of this pull request:
Screenshot from 2023-01-24 13-07-23

I think this is good enough for now, but eventually we would want an error message that makes clear that the error originated from a panic in the model code, and add as much detail as possible (file name, line, etc.).

None of this needs to be a part of this pull request. I'm just making a note, so I remember to open an issue, once this is merged.

crates/fj/src/abi/context.rs Outdated Show resolved Hide resolved
crates/fj/src/abi/model.rs Outdated Show resolved Hide resolved
@mxdamien
Copy link
Contributor Author

Thanks for the review Hanno. I'll see what I can do and come back with questions for sure ;)

  • David

@hannobraun
Copy link
Owner

Thank you, David!

@mxdamien mxdamien force-pushed the feat/ShowStatusInUIAfterPanicInModel branch from 9078292 to bbd03e8 Compare January 29, 2023 14:40
@mxdamien mxdamien marked this pull request as draft January 29, 2023 14:40
@mxdamien mxdamien force-pushed the feat/ShowStatusInUIAfterPanicInModel branch 9 times, most recently from 0f0ddc2 to 17cfef2 Compare February 7, 2023 07:53
@mxdamien mxdamien force-pushed the feat/ShowStatusInUIAfterPanicInModel branch from 17cfef2 to c89b948 Compare February 7, 2023 07:57
@mxdamien
Copy link
Contributor Author

mxdamien commented Feb 7, 2023

Hi !

I hope I've addressed your remarks. I'm not entirely sure about the usage of the different internal / ffi-boundary structs. It's my first time dealing with this kind of stuff in Rust.

David

@mxdamien mxdamien marked this pull request as ready for review February 7, 2023 08:11
@hannobraun
Copy link
Owner

Thank you for keeping at it, David! I'll take a look later today.

Copy link
Owner

@hannobraun hannobraun left a comment

Choose a reason for hiding this comment

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

Thank you, @mxdamien! This is looking great!

I've left one comment about a thing I don't like, but I decided to merge the pull request anyway. Panics in the model code are properly handled now, and I believe that the error being swallowed there is a corner case.

I'm going to open an issue to track that. Feel free to follow up with another pull request to address it, if you want.

false => Some(other.into_str()),
}
}
super::ffi_safe::Result::Err(_) => None,
Copy link
Owner

Choose a reason for hiding this comment

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

It's not ideal to swallow the error here, as that could cause bugs to be hidden. Instead of getting an error message, making it clear that a bug has occurred, it could lead to a specified argument just not being recognized, which would be very confusing.

I think Context::get_argument should also return Result instead of an Option.

@hannobraun hannobraun merged commit ed08c4c into hannobraun:main Feb 7, 2023
@hannobraun
Copy link
Owner

I've opened the following issues in response to this pull requests:

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.

Panic in model crashes the app
2 participants