-
What would be the best approach to return errors back to dart? So far I'm thinking that creating a protobuf message with an enum is the only available option e.g. syntax = "proto3";
// [DART-SIGNAL]
message MyMessage {}
// [RUST-SIGNAL]
message MyMessageResult {
oneof result {
string message = 1; // Contains a message if the Rust code was successful
Error error = 2; // returns an error if the Rust code fails
}
}
// Your implementation of an error. It might include a call stack, or an error code etc.
message Error {
string message = 1; // Human-readable explanation of the error
} |
Beta Was this translation helpful? Give feedback.
Answered by
temeddix
Oct 25, 2024
Replies: 1 comment 4 replies
-
As stated in the documentation, Rinf expects developers to use Flutter exclusively for the UI layer, while keeping all business logic in Rust. This approach encourages handling errors and logging directly in Rust. Personally, I use the |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this message type is a good idea in general. However I use this error message independently with
[RUST-SIGNAL]
, not by including it inside another message, when I write my app.Also I recommend you not to write panicking code at all, since Rust have idiomatic
Result<T, E>
. Also, Rust cannot catch panics on the web platform(wasm32-unknown-unknown
), making all callers wait forever.The function signature of your intent would look like this: