@@ -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 }
0 commit comments