Why every method from Location returns a Result<T, JsValue>?
#3713
-
|
Hi I'd like to understand the reasoning behind the setting return value of every methods from the Lets take Following the MDN WebAPI for Why then, instead of returning Trying to study and understand by myself, I found out that |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
...Except, the (Copying Firefox's WebIDL instead of using the versions from the actual standards has led to some issues before, e.g. #3227, although I can't remember any particular cases where something was incorrectly annotated with As for whether or not it should return
Apparently it can throw a |
Beta Was this translation helpful? Give feedback.
web-sysis automatically generated from a pile of 'WebIDL' files here, which is how web APIs define their interfaces. In particular, it decides whether or not a function or getter should return aResultbased on whether it's annotated with a[Throws]attribute in WebIDL, whichlocation.originis:https://github.com/rustwasm/wasm-bindgen/blob/bb12058e1facd26c5c647282a125088535be577e/crates/web-sys/webidls/enabled/Location.webidl#L25-L26
...Except, the
[Throws]attribute isn't actually an official part of WebIDL. It's a custom addition used by Firefox, which is whereweb-syscopied most of its WebIDL from. So, the answer to why it returnsResultis pretty much 'because Firefox thought it sh…