improve showing compilation exception details in YellowBox
Figwheel logs compilation exception in several log messages, so need to buffer them to show in YellowBox. - buffering starts on "Fighweel: Compile Exception" - buffering stops on "Error on file"
This commit is contained in:
parent
44127ab930
commit
29ede22315
|
@ -164,8 +164,25 @@ function interceptRequire() {
|
||||||
function compileWarningsToYellowBox() {
|
function compileWarningsToYellowBox() {
|
||||||
var log = window.console.log;
|
var log = window.console.log;
|
||||||
var compileWarningRx = /Figwheel: Compile/;
|
var compileWarningRx = /Figwheel: Compile/;
|
||||||
|
var compileExceptionRx = /Figwheel: Compile Exception/;
|
||||||
|
var errorInFileRx = /Error on file/;
|
||||||
|
var isBuffering = false;
|
||||||
|
var compileExceptionBuffer = "";
|
||||||
window.console.log = function (msg) {
|
window.console.log = function (msg) {
|
||||||
if (compileWarningRx.test(msg)) {
|
if (compileExceptionRx.test(msg)) { // enter buffering mode to get all the messages for exception
|
||||||
|
log.apply(window.console, arguments);
|
||||||
|
isBuffering = true;
|
||||||
|
compileExceptionBuffer = msg + "\n";
|
||||||
|
} else if (errorInFileRx.test(msg) && isBuffering) { // exit buffering mode and log buffered messages to YellowBox
|
||||||
|
log.apply(window.console, arguments);
|
||||||
|
isBuffering = false;
|
||||||
|
console.warn(compileExceptionBuffer + msg);
|
||||||
|
compileExceptionBuffer = "";
|
||||||
|
} else if (isBuffering) { //log messages buffering mode
|
||||||
|
log.apply(window.console, arguments);
|
||||||
|
compileExceptionBuffer += msg + "\n";
|
||||||
|
} else if (compileWarningRx.test(msg)) {
|
||||||
|
log.apply(window.console, arguments);
|
||||||
console.warn(msg);
|
console.warn(msg);
|
||||||
} else {
|
} else {
|
||||||
log.apply(window.console, arguments);
|
log.apply(window.console, arguments);
|
||||||
|
|
Loading…
Reference in New Issue