dominikh / go-js-dom

MIT License
252 stars 42 forks source link

Add an Error type #6

Open dominikh opened 10 years ago

dominikh commented 10 years ago

Add a type Error, which acts as a combination of DOMException and DOMError. It should be returned from methods such as (*HTMLInputElement).StepDown, which are documented to throw exceptions in case of abnormal conditions.

When we catch an exception that isn't of type DOMException¹, we should throw it again, as it's of a different nature.

We should also consider adding one variable per possible error type (e.g. InvalidStateError), so that one can check directly against those, instead of requiring more constants and comparing fields of Error to those.

Finally, find out whether all modern browsers have the name property, or if we need to implement a fallback that looks at code instead.

¹: Only DOMException will actually be thrown, DOMError is some internal name. ²: https://developer.mozilla.org/en-US/docs/Web/API/DOMError and https://developer.mozilla.org/en/docs/Web/API/DOMException will serve as guidance.