Search code examples
google-chrome-devtoolsclojurescriptsource-mapsclojurescript-javascript-interop

Use sourcemap on browser onerror in ClojureScript on Crome


I have a error listener (set! (.-onerror js/window)(fn [message source lineno colno error]... like this on browser and it works well, but stacktrace and other fields are in JS. I would like it to be translated to ClojureScript. I guess source maps would help?


Solution

  • It is unclear what you mean when you say you would like it to be converted to ClojureScript.

    If you want to convert the stacktrace to show ClojureScript source location then you'll need the source maps yes. It is impractical to do this on the client side though since source maps can be quite big.

    You can get the other properties via JS interop. The stacktrace you'd get via (.-stack error) but it is a plain string and the format varies between browsers so some custom parsing might be required. There are third party services that will do this for you if you but they'll also need the source maps.