Permalink
Browse files

Use throw rather than assert.

The latter gets compiled away, so it's not too useful at runtime.
  • Loading branch information...
1 parent 1a2f7b0 commit 25f179662a50dbd646d0a860a2032e5a6d9dcb98 @mrdomino committed Jan 3, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 message.js
View
@@ -11,7 +11,7 @@ goog.require('goog.crypt.Sha1');
message.Message;
/**
- * @param {string} str String to encode.
+ * @param {!string} str String to encode.
* @return {message.Message} Encoded message.
*/
message.encode = function(str) {
@@ -31,7 +31,9 @@ message.encode = function(str) {
* @return {string} Decoded string.
*/
message.decode = function(bytes) {
- goog.asserts.assert(message.verify(bytes), "Invalid message!");
+ if (!message.verify(bytes)) {
+ throw new Error("Invalid message");
+ }
var msg = new Uint8Array(bytes, 21);
return message.utf8Decode_(message.bytesToString_(msg));
}

0 comments on commit 25f1796

Please sign in to comment.