Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit 70f68da

Browse files
committed
fix(errors): runtime error immediately, selectable stack
1 parent 09e9f43 commit 70f68da

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

bin/ion-dev.js

+17-8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ window.IonicDevServer = {
4141
handleError: function(err) {
4242
if (!err) return;
4343

44+
// Socket is ready so send this error to the server for prettifying
4445
if (this.socketReady) {
4546
var msg = {
4647
category: 'runtimeError',
@@ -168,6 +169,9 @@ window.IonicDevServer = {
168169
}
169170
},
170171

172+
/**
173+
* Process a build update message and display something to the friendly user.
174+
*/
171175
buildUpdate: function(msg) {
172176
var status = 'success';
173177

@@ -187,6 +191,8 @@ window.IonicDevServer = {
187191
this.buildingNotification(false);
188192

189193
var diagnosticsEle = document.getElementById('ion-diagnostics');
194+
195+
// If we have an element but no html created yet
190196
if (diagnosticsEle && !msg.data.diagnosticsHtml) {
191197
diagnosticsEle.classList.add('ion-diagnostics-fade-out');
192198

@@ -199,21 +205,24 @@ window.IonicDevServer = {
199205

200206
} else if (msg.data.diagnosticsHtml) {
201207

202-
clearTimeout(this.diagnosticsTimerId);
208+
// We don't have an element but we have diagnostics HTML, so create the error
203209

204210
if (!diagnosticsEle) {
205211
diagnosticsEle = document.createElement('div');
206212
diagnosticsEle.id = 'ion-diagnostics';
207213
diagnosticsEle.className = 'ion-diagnostics-fade-out';
208214
document.body.insertBefore(diagnosticsEle, document.body.firstChild);
209-
210-
this.diagnosticsTimerId = setTimeout(function() {
211-
var diagnosticsEle = document.getElementById('ion-diagnostics');
212-
if (diagnosticsEle) {
213-
diagnosticsEle.classList.remove('ion-diagnostics-fade-out');
214-
}
215-
}, 24);
216215
}
216+
217+
// Show the last error
218+
clearTimeout(this.diagnosticsTimerId);
219+
this.diagnosticsTimerId = setTimeout(function() {
220+
var diagnosticsEle = document.getElementById('ion-diagnostics');
221+
if (diagnosticsEle) {
222+
diagnosticsEle.classList.remove('ion-diagnostics-fade-out');
223+
}
224+
}, 24);
225+
217226
diagnosticsEle.innerHTML = msg.data.diagnosticsHtml
218227
}
219228
}

src/dev-client/sass/_stack-block.scss

+3
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@
1414
white-space: pre;
1515
overflow: auto;
1616
padding: 10px;
17+
18+
user-select: auto;
19+
-webkit-user-select: text;
1720
}

0 commit comments

Comments
 (0)