Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use throw rather than assert.

The latter gets compiled away, so it's not too useful at runtime.
  • Loading branch information...
commit 25f179662a50dbd646d0a860a2032e5a6d9dcb98 1 parent 1a2f7b0
@mrdomino authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 message.js
View
6 message.js
@@ -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));
}
Please sign in to comment.
Something went wrong with that request. Please try again.