Use thiserror crate for webdriver
Categories
(Testing :: geckodriver, enhancement)
Tracking
(firefox122 fixed)
Tracking | Status | |
---|---|---|
firefox122 | --- | fixed |
People
(Reporter: whimboo, Assigned: jameshendry05, Mentored)
References
Details
(Whiteboard: [lang=rust])
Attachments
(1 file)
With bug 1739307 we got the thiserror crate to be used for our mozbase-rust crates. Now we can also update our webdriver code to make use of it as well.
Code that needs to be updated:
Reporter | ||
Updated•1 year ago
|
Assignee | ||
Comment 1•1 year ago
|
||
Would love to work on more of this. I already had my eye on what to do next and seems that https://bugzilla.mozilla.org/show_bug.cgi?id=1682239 is a partial duplicate of this that you made a while ago. Happy to work on both/either though, just let me know which bug to target first.
Reporter | ||
Comment 2•1 year ago
|
||
Ah good point! I completely missed that other bug. I've updated it now so that it will cover the anyhow
create for geckodriver, while for the webdriver crate we should still use thiserror
.
Glad to see that you are interested James!
Assignee | ||
Comment 3•1 year ago
|
||
Updated•1 year ago
|
Assignee | ||
Comment 4•1 year ago
|
||
From what I can see the only thing that implments the Error trait in webdriver is WebDriverError, so this is the only thing I have converted.
Additionally something I wanted to flag up:
ttps://searchfox.org/mozilla-central/source/testing/webdriver/src/error.rs#209
UnknownCommand | UnknownError => "unknown error",
But:
https://searchfox.org/mozilla-central/source/testing/webdriver/src/error.rs#285
"unknown command" => UnknownCommand,
"unknown error" => UnknownError,
This seems odd to me - it means that converting an "unknown command" to the enum, then re-serialising it would yield "unknown error". This may be intentional though - in which case maybe a reference / comment may be warranted.
Reporter | ||
Comment 5•1 year ago
|
||
(In reply to jameshendry05 from comment #4)
From what I can see the only thing that implments the Error trait in webdriver is WebDriverError, so this is the only thing I have converted.
Great, I will have a look soon. And yes, there shouldn't be much more to do.
Additionally something I wanted to flag up:
https://searchfox.org/mozilla-central/source/testing/webdriver/src/error.rs#209UnknownCommand | UnknownError => "unknown error",
Oh, good find! It looks like a bug to me that we should get fixed. From what I can see it should actually be or'ed with UnknownPath
given that this will also lead to the unknown command
error. Would you mind filing a new bug for that in the Testing :: geckodriver
component?
Assignee | ||
Comment 6•1 year ago
|
||
Comment 8•1 year ago
|
||
bugherder |
Reporter | ||
Comment 9•1 year ago
|
||
James, again thanks a lot for your contribution! In case you have still interest on bug 1682239 I would appreciate that, because then we have a better error handling across all of our rust crates related to geckodriver.
Description
•