Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: background.js

Issue 5655474749833216: Issue 2658 - Got rid of try..catch for filter validation (Closed)
Patch Set: Improved comments Created June 8, 2015, 11:59 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/filterValidation.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: background.js
===================================================================
--- a/background.js
+++ b/background.js
@@ -360,19 +360,16 @@
}
break;
case "add-filters":
- var filters;
- try
+ var result = parseFilters(msg.text);
+
+ if (result.error)
{
- filters = parseFilters(msg.text);
- }
- catch (error)
- {
- sendResponse({status: "invalid", error: error});
+ sendResponse({status: "invalid", error: result.error});
break;
}
- for (var i = 0; i < filters.length; i++)
- FilterStorage.addFilter(filters[i]);
+ for (var i = 0; i < result.filters.length; i++)
+ FilterStorage.addFilter(result.filters[i]);
sendResponse({status: "ok"});
break;
« no previous file with comments | « no previous file | lib/filterValidation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld