From 57d8e53111490af86274d13e76ccc8da382e6cea Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Wed, 18 Sep 2019 12:17:34 +0100 Subject: [PATCH] Catch errors during document initialization Change-Id: I5dc29666f99ac10bbf63a56153ba9a32d3568daa Depends-On: I57fb6319bc3a9cee347c39fc75f555543991d703 --- .../ve-mw-collab/ve.init.mw.CollabTarget.init.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/ve-mw-collab/ve.init.mw.CollabTarget.init.js b/modules/ve-mw-collab/ve.init.mw.CollabTarget.init.js index 5919f3c18e..b7df7a2d0a 100644 --- a/modules/ve-mw-collab/ve.init.mw.CollabTarget.init.js +++ b/modules/ve-mw-collab/ve.init.mw.CollabTarget.init.js @@ -92,7 +92,7 @@ dummySurface.createProgress( progressDeferred.promise(), ve.msg( 'visualeditor-rebase-client-connecting' ), true ); - surfaceModel.synchronizer.once( 'initDoc', function () { + surfaceModel.synchronizer.once( 'initDoc', function ( error ) { var initPromise; progressDeferred.resolve(); @@ -102,6 +102,18 @@ target.clearSurfaces(); // Don't add the surface until the history has been applied target.addSurface( surfaceModel ); + if ( error ) { + OO.ui.alert( + $( '

' ).append( + ve.htmlMsg( 'visualeditor-corrupted-document-error', $( '

' ).text( error.stack ) )
+							),
+							{ title: ve.msg( 'visualeditor-corrupted-document-title' ), size: 'large' }
+						).then( function () {
+							// eslint-disable-next-line no-use-before-define
+							showForm( true );
+						} );
+						return;
+					}
 					target.once( 'surfaceReady', function () {
 						initPromise.then( function () {
 							surfaceModel.selectFirstContentOffset();
@@ -184,7 +196,7 @@
 		} ).fail( function ( err ) {
 			mw.log.error( err );
 			// eslint-disable-next-line no-use-before-define
-			showForm();
+			showForm( true );
 		} );
 	}