Skip to content
Discussion options

You must be logged in to vote

You can't return a result from the update function, but what you can do is store the error as part of your application state. So something like:

struct App {
	last_result: Result<(), Error>,
}

impl Sandbox for App {
	fn update(&mut self, message: Message) {
		match message {
			Message::Something => {
				let result = do_something();
				if result.is_err() {
					self.last_result = result;
				}
			}
		}
	}
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@d-mceneaney
Comment options

@Levitanus
Comment options

@ILikeTeaALot
Comment options

Answer selected by d-mceneaney
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants