Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(755)

Unified Diff: pkg/analysis_server/lib/src/edit/edit_domain.dart

Issue 815233002: Catch exceptions in refactorings and return them as a SERVER_ERROR. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/protocol.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/edit/edit_domain.dart
diff --git a/pkg/analysis_server/lib/src/edit/edit_domain.dart b/pkg/analysis_server/lib/src/edit/edit_domain.dart
index eb4bbf4168048e48f85e8edb1dc7d178282fc1c9..8dcf11568742e36b4a3979d812964919204f493e 100644
--- a/pkg/analysis_server/lib/src/edit/edit_domain.dart
+++ b/pkg/analysis_server/lib/src/edit/edit_domain.dart
@@ -26,6 +26,13 @@ import 'package:analyzer/src/generated/source.dart';
/**
+ * This flag is used in tests to check behavior when an exception happens
+ * inside a refactoring.
+ */
+bool test_simulateRefactoringException = false;
+
+
+/**
* Instances of the class [EditDomainHandler] implement a [RequestHandler]
* that handles requests in the edit domain.
*/
@@ -286,6 +293,10 @@ class _RefactoringManager {
return _sendResultResponse();
});
});
+ }).catchError((exception, stackTrace) {
+ _reset();
+ server.sendResponse(
+ new Response.serverError(request, exception, stackTrace));
});
}
@@ -307,6 +318,10 @@ class _RefactoringManager {
this.file = file;
this.offset = offset;
this.length = length;
+ // simulate an exception
+ if (test_simulateRefactoringException) {
+ throw 'A simulated refactoring exception.';
+ }
// create a new Refactoring instance
if (kind == RefactoringKind.CONVERT_GETTER_TO_METHOD) {
List<Element> elements = server.getElementsAtOffset(file, offset);
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/protocol.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698