google / jsinterop-base

Utilities for GWT and J2CL to interact with JavaScript beyond JsInterop
Apache License 2.0
67 stars 16 forks source link

Translating between native and java errors? #13

Closed realityforge closed 5 years ago

realityforge commented 5 years ago

Is there a "standard" way of translating back and forth between native and java errors/throwables? It is unclear to me where this would belong. i.e. here or Elemental2 or maybe tucked away in the JRE emulation layer.

At the moment in our GWT code I am doing the equivalent of JsError error = Js.uncheckedCast(Js.asPropertyMap( e ).nestedGet( "backingJsObject" )) but this feels like it is prone to breakage when moving to J2cl where backingJsObject is potentially renamed.

Is there a location where this could be added that would be accepted?

jDramaix commented 5 years ago

Throwable class has a getBackingJsObject() method to get the js errors. If you want to get back to java throwable from js error, us Throwable.of(backingJsObject)