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

Unified Diff: ui/webui/resources/js/assert.js

Issue 405743002: Typecheck some of ui/webui/resources/js/ with Closure compiler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cr.isMac fix Created 6 years, 4 months 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
Index: ui/webui/resources/js/assert.js
diff --git a/ui/webui/resources/js/assert.js b/ui/webui/resources/js/assert.js
index bae2910705bd3eb77270c46cf7ec1fb6dbac82a0..7b38398ed0175179cfc6efaf510b489a73bbf591 100644
--- a/ui/webui/resources/js/assert.js
+++ b/ui/webui/resources/js/assert.js
@@ -22,3 +22,28 @@ function assert(condition, opt_message) {
throw new Error(msg);
}
}
+
+/**
+ * Call this from places in the code that should never be reached.
+ *
+ * For example, handling all the values of enum with a switch() like this:
+ *
+ * function getValueFromEnum(enum) {
+ * switch (enum) {
+ * case ENUM_FIRST_OF_TWO:
+ * return first
+ * case ENUM_LAST_OF_TWO:
+ * return last;
+ * }
+ * assertNotReached();
+ * return document;
+ * }
+ *
+ * This code should only be hit in the case of serious programmer error or
+ * unexpected input.
+ *
+ * @param {string=} opt_message A message to show when this is hit.
+ */
+function assertNotReached(opt_message) {
+ throw new Error(opt_message || "Unreachable code hit");
+}
« no previous file with comments | « third_party/closure_compiler/externs/pending_compiler_externs.js ('k') | ui/webui/resources/js/chromeos/ui_account_tweaks.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698