Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 428801

Summary: InputManager needs to handle errors coming from non-Orion servers.
Product: [ECD] Orion Reporter: libing wang <libingw>
Component: ClientAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Silenio_Quarti, simon_kaegi
Version: 5.0Flags: Silenio_Quarti: review+
simon_kaegi: review+
Target Milestone: 5.0 RC3   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 428791    

Description libing wang CLA 2014-02-21 15:56:23 EST
The inputManager generic error translation assumes that the error.responseText always has Severity and Message properties.

But is the error comes from non orion server, it might be different format.
Comment 1 libing wang CLA 2014-02-21 15:57:57 EST
Proposed fix:

diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/inputManager.js b/bundles/org.eclipse.orion.client.ui/web/orion/inputManager.js
index 7b59052..ef9a61f 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/inputManager.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/inputManager.js
@@ -64,8 +64,9 @@
 			window.console.log(error);
 			return;
 		}
+		var newError;
 		if (error.status === 0) {
-			error = {
+			newError = {
 				Severity: "Error", //$NON-NLS-0$
 				Message: messages.noResponse
 			};
@@ -73,17 +74,28 @@
 			var responseText = error.responseText;
 			if (responseText) {
 				try {
-					error = JSON.parse(responseText);
+					newError = JSON.parse(responseText);
 				} catch(e) {
-					error = {
+					newError = {
 						//HTML: true,
 						Severity: "Error", //$NON-NLS-0$
 						Message: responseText
 					};
 				}
+				if(!newError.Severity) {
+					newError.Severity = "Error"; //$NON-NLS-0$
+				}
+				if(!newError.Message) {
+					newError.Message = responseText;
+				}
+			} else {
+				newError = {
+					Severity: "Error", //$NON-NLS-0$
+					Message: JSON.stringify(error)
+				};
 			}
 		}
-		statusService.setProgressResult(error);
+		statusService.setProgressResult(newError);
 	}
 
 	/**
@@ -551,6 +563,7 @@
 		}
 	});
 	return {
+		handleError: handleError,
 		InputManager: InputManager
 	};
 });
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/browse/fileBrowser.js b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/browse/fileBrowser.js
index 0272474..b63f250 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/browse/fileBrowser.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/browse/fileBrowser.js
@@ -329,6 +329,10 @@
 						}
 					}
 					this.refresh(PageUtil.hash());
+				}.bind(this),
+				function(error){
+					console.log(error);
+					mInputManager.handleError(this._statusService, error);
 				}.bind(this));
 			} else {
 				this.refresh(PageUtil.hash());