google / wasefire

Secure firmware framework focusing on developer experience
https://google.github.io/wasefire/
Apache License 2.0
86 stars 20 forks source link

Improve Rust prelude error messages #43

Open ia0 opened 1 year ago

ia0 commented 1 year ago

When calling the prelude with wrong arguments, instead of panicking without error message, an error message could describe the problem. For example when calling led::set() with an out-of-bound index.

Ideas:

Sub-tasks:

lukeyeh commented 6 months ago

Prelude functions should panic on errors that the user could have prevented (e.g. out of bound index).

Hey just to make sure I understand this point. By panicking do you mean using scheduling::abort somewhere in the applet? or panicking somewhere in the scheduler using log::panic!

For example, for dealing with an index out of bounds error on led::set. I assume we would have to get the out-of-bounds-error from here. Then,

ia0 commented 6 months ago

I assume we would have to get the out-of-bounds-error from here.

Yes, we would need to return an error there instead of a trap. Then the prelude would simply unwrap the result (maybe it does do already) with a track_caller attribute for the panic location to be in the user code.

No need to call scheduling abort, that should be automatic when panicking.

Also we should never panic in the scheduler.