Scala's throw expects a Throwable, which js.Error is not.
I need to re-throw a JS error that was provided to me by a third party JS lib. Said lib will then catch that re-thrown error again and do something about it.
I could write a one-line npm module in JS: module.exports = function (e) { throw e; }, and add it to my npmDependencies, but I was wondering if there is a better solution for this.
You have to wrap the JS error in a js.JavaScriptException:
import scala.scalajs.js
throw js.JavaScriptException(e)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With