[ReactNative] Support loading sourcemaps from sourceMappingURL

This commit is contained in:
Alex Kotliarskyi
2015-03-12 17:49:54 -07:00
parent 963bb036e0
commit 6299803081
7 changed files with 157 additions and 18 deletions

View File

@@ -57,6 +57,8 @@ function setupDocumentShim() {
}
}
var sourceMapPromise;
function handleErrorWithRedBox(e) {
var RKExceptionsManager = require('NativeModules').RKExceptionsManager;
var errorToString = require('errorToString');
@@ -73,13 +75,14 @@ function handleErrorWithRedBox(e) {
if (RKExceptionsManager) {
RKExceptionsManager.reportUnhandledException(e.message, errorToString(e));
if (__DEV__) {
try {
var sourceMapInstance = loadSourceMap();
var prettyStack = errorToString(e, sourceMapInstance);
RKExceptionsManager.updateExceptionMessage(e.message, prettyStack);
} catch (ee) {
GLOBAL.console.error('#CLOWNTOWN (error while displaying error): ' + ee.message);
}
(sourceMapPromise = sourceMapPromise || loadSourceMap())
.then(map => {
var prettyStack = errorToString(e, map);
RKExceptionsManager.updateExceptionMessage(e.message, prettyStack);
})
.then(null, error => {
GLOBAL.console.error('#CLOWNTOWN (error while displaying error): ' + error.message);
});
}
}
}