Major update: Fix bug: Rename "new Exception" to "new Error" througout the project.
diff --git a/js/ContentName.js b/js/ContentName.js
index 249cfbe..d0d7711 100644
--- a/js/ContentName.js
+++ b/js/ContentName.js
@@ -89,7 +89,7 @@
ContentName.prototype.to_ccnb = function(/*XMLEncoder*/ encoder) {
if( this.components ==null )
- throw new Exception("CANNOT ENCODE EMPTY CONTENT NAME");
+ throw new Error("CANNOT ENCODE EMPTY CONTENT NAME");
encoder.writeStartElement(this.getElementLabel());
var count = this.components.length;
diff --git a/js/FaceInstance.js b/js/FaceInstance.js
index 78ac5de..f19d523 100644
--- a/js/FaceInstance.js
+++ b/js/FaceInstance.js
@@ -81,7 +81,7 @@
} else {
- throw new Exception("FaceInstance.decoder. Invalid " +
+ throw new Error("FaceInstance.decoder. Invalid " +
CCNProtocolDTags.tagToString(CCNProtocolDTags.IPProto) + " field: " + pI);
}
@@ -119,8 +119,8 @@
encoder){
//if (!this.validate()) {
- //throw new Exception("Cannot encode : field values missing.");
- //throw new Exception("")
+ //throw new Error("Cannot encode : field values missing.");
+ //throw new Error("")
//}
encoder.writeStartElement(this.getElementLabel());
diff --git a/js/KeyLocator.js b/js/KeyLocator.js
index 96df104..14f283c 100644
--- a/js/KeyLocator.js
+++ b/js/KeyLocator.js
@@ -46,11 +46,11 @@
} catch (e) {
- throw new Exception("Cannot parse key: ", e);
+ throw new Error("Cannot parse key: ", e);
}
if (null == this.publicKey) {
- throw new Exception("Cannot parse key: ");
+ throw new Error("Cannot parse key: ");
}
} else if ( decoder.peekStartElement(CCNProtocolDTags.Certificate)) {
@@ -71,10 +71,10 @@
if(LOG>4) console.log('CERTIFICATE FOUND: '+ this.certificate);
} catch ( e) {
- throw new Exception("Cannot decode certificate: " + e);
+ throw new Error("Cannot decode certificate: " + e);
}
if (null == this.certificate) {
- throw new Exception("Cannot parse certificate! ");
+ throw new Error("Cannot parse certificate! ");
}
} else {
this.type = 1;
@@ -108,7 +108,7 @@
try {
encoder.writeElement(CCNProtocolDTags.Certificate, this.certificate);
} catch ( e) {
- throw new Exception("CertificateEncodingException attempting to write key locator: " + e);
+ throw new Error("CertificateEncodingException attempting to write key locator: " + e);
}
} else if (this.type == KeyLocatorType.NAME) {
diff --git a/js/KeyName.js b/js/KeyName.js
index e958c3f..ccbda2a 100644
--- a/js/KeyName.js
+++ b/js/KeyName.js
@@ -32,7 +32,7 @@
KeyName.prototype.to_ccnb = function( encoder) {
if (!this.validate()) {
- throw new Exception("Cannot encode : field values missing.");
+ throw new Error("Cannot encode : field values missing.");
}
encoder.writeStartElement(this.getElementLabel());
diff --git a/js/PublisherID.js b/js/PublisherID.js
index 3558d24..e418d57 100644
--- a/js/PublisherID.js
+++ b/js/PublisherID.js
@@ -49,13 +49,13 @@
var nextTag = decoder.peekStartElementAsLong();
if (null == nextTag) {
- throw new Exception("Cannot parse publisher ID.");
+ throw new Error("Cannot parse publisher ID.");
}
this.publisherType = new PublisherType(nextTag);
if (!isTypeTagVal(nextTag)) {
- throw new Exception("Invalid publisher ID, got unexpected type: " + nextTag);
+ throw new Error("Invalid publisher ID, got unexpected type: " + nextTag);
}
this.publisherID = decoder.readBinaryElement(nextTag);
if (null == this.publisherID) {
@@ -65,7 +65,7 @@
PublisherID.prototype.to_ccnb = function(encoder) {
if (!this.validate()) {
- throw new Exception("Cannot encode " + this.getClass().getName() + ": field values missing.");
+ throw new Error("Cannot encode " + this.getClass().getName() + ": field values missing.");
}
encoder.writeElement(this.getElementLabel(), this.publisherID);
diff --git a/js/PublisherPublicKeyDigest.js b/js/PublisherPublicKeyDigest.js
index 50f856c..6cae7f6 100644
--- a/js/PublisherPublicKeyDigest.js
+++ b/js/PublisherPublicKeyDigest.js
@@ -21,7 +21,7 @@
if(LOG>4)console.log('Publisher public key digest is ' + this.publisherPublicKeyDigest);
if (null == this.publisherPublicKeyDigest) {
- throw new Exception("Cannot parse publisher key digest.");
+ throw new Error("Cannot parse publisher key digest.");
}
//TODO check if the length of the PublisherPublicKeyDigest is correct ( Security reason)
@@ -38,7 +38,7 @@
PublisherPublicKeyDigest.prototype.to_ccnb= function( encoder) {
//TODO Check that the ByteArray for the key is present
if (!this.validate()) {
- throw new Exception("Cannot encode : field values missing.");
+ throw new Error("Cannot encode : field values missing.");
}
if(LOG>3) console.log('PUBLISHER KEY DIGEST IS'+this.publisherPublicKeyDigest);
encoder.writeElement(this.getElementLabel(), this.publisherPublicKeyDigest);
diff --git a/js/Signature.js b/js/Signature.js
index 9672b3f..6b71dad 100644
--- a/js/Signature.js
+++ b/js/Signature.js
@@ -60,7 +60,7 @@
Signature.prototype.to_ccnb= function( encoder){
if (!this.validate()) {
- throw new Exception("Cannot encode: field values missing.");
+ throw new Error("Cannot encode: field values missing.");
}
encoder.writeStartElement(this.getElementLabel());
diff --git a/js/SignedInfo.js b/js/SignedInfo.js
index 909545a..f398c4c 100644
--- a/js/SignedInfo.js
+++ b/js/SignedInfo.js
@@ -109,7 +109,7 @@
if (null == this.type) {
- throw new Exception("Cannot parse signedInfo type: bytes.");
+ throw new Error("Cannot parse signedInfo type: bytes.");
}
} else {
@@ -135,7 +135,7 @@
SignedInfo.prototype.to_ccnb = function( encoder) {
if (!this.validate()) {
- throw new Exception("Cannot encode : field values missing.");
+ throw new Error("Cannot encode : field values missing.");
}
encoder.writeStartElement(this.getElementLabel());
diff --git a/js/encoding/BinaryXMLCodec.js b/js/encoding/BinaryXMLCodec.js
index b1befdd..e6b8fef 100644
--- a/js/encoding/BinaryXMLCodec.js
+++ b/js/encoding/BinaryXMLCodec.js
@@ -61,14 +61,14 @@
offset) {
if ((type > XML_UDATA) || (type < 0) || (val < 0)) {
- throw new Exception("Tag and value must be positive, and tag valid.");
+ throw new Error("Tag and value must be positive, and tag valid.");
}
// Encode backwards. Calculate how many bytes we need:
var/*int*/ numEncodingBytes = numEncodingBytes(val);
if ((offset + numEncodingBytes) > buf.length) {
- throw new Exception("Buffer space of " + (buf.length-offset) +
+ throw new Error("Buffer space of " + (buf.length-offset) +
" bytes insufficient to hold " +
numEncodingBytes + " of encoded type and value.");
}
@@ -104,7 +104,7 @@
offset) {
if ((type > XML_UDATA) || (type < 0) || (val < 0)) {
- throw new Exception("Tag and value must be positive, and tag valid.");
+ throw new Error("Tag and value must be positive, and tag valid.");
}
// Encode backwards. Calculate how many bytes we need:
@@ -112,7 +112,7 @@
var numEncodingBytes = numEncodingBytes(val);
if ((offset + numEncodingBytes) > buf.length) {
- throw new Exception("Buffer space of " + (buf.length-offset) +
+ throw new Error("Buffer space of " + (buf.length-offset) +
" bytes insufficient to hold " +
numEncodingBytes + " of encoded type and value.");
}
@@ -137,7 +137,7 @@
--i;
}
if (val != 0) {
- throw new Exception( "This should not happen: miscalculated encoding");
+ throw new Error( "This should not happen: miscalculated encoding");
//Log.warning(Log.FAC_ENCODING, "This should not happen: miscalculated encoding length, have " + val + " left.");
}
diff --git a/js/encoding/BinaryXMLDecoder.js b/js/encoding/BinaryXMLDecoder.js
index c41d549..41a4e45 100644
--- a/js/encoding/BinaryXMLDecoder.js
+++ b/js/encoding/BinaryXMLDecoder.js
@@ -86,7 +86,7 @@
tv = this.decodeTypeAndVal(this.istream);
if (null == tv) {
- throw new Exception("Expected start element: " + startTag + " got something not a tag.");
+ throw new Error("Expected start element: " + startTag + " got something not a tag.");
}
//String
@@ -101,7 +101,7 @@
}
if ((null == decodedTag) || decodedTag != startTag) {
- throw new Exception("Expected start element: " + startTag + " got: " + decodedTag + "(" + tv.val() + ")");
+ throw new Error("Expected start element: " + startTag + " got: " + decodedTag + "(" + tv.val() + ")");
}
if (null != attributes) {
@@ -109,7 +109,7 @@
}
} catch (e) {
- throw new Exception("readStartElement", e);
+ throw new Error("readStartElement", e);
}
};
@@ -189,7 +189,7 @@
tv = this.decodeTypeAndVal(this.istream);
if (null == tv) {
- throw new Exception("Expected start element: " + startTag + " got something not a tag.");
+ throw new Error("Expected start element: " + startTag + " got something not a tag.");
}
//String
@@ -227,7 +227,7 @@
if ((null == decodedTag) || decodedTag != startTag ) {
console.log('expecting '+ startag + ' but got '+ decodedTag);
- throw new Exception("Expected start element: " + startTag + " got: " + decodedTag + "(" + tv.val() + ")");
+ throw new Error("Expected start element: " + startTag + " got: " + decodedTag + "(" + tv.val() + ")");
}
// DKS: does not read attributes out of stream if caller doesn't
@@ -239,7 +239,7 @@
//} catch ( e) {
//console.log(e);
- //throw new Exception("readStartElement", e);
+ //throw new Error("readStartElement", e);
//}
}
@@ -281,7 +281,7 @@
// DKS TODO are attributes same or different dictionary?
attributeName = tagToString(thisTV.val());
if (null == attributeName) {
- throw new Exception("Unknown DATTR value" + thisTV.val());
+ throw new Error("Unknown DATTR value" + thisTV.val());
}
}
// Attribute values are always UDATA
@@ -296,7 +296,7 @@
} catch ( e) {
Log.logStackTrace(Log.FAC_ENCODING, Level.WARNING, e);
- throw new Exception("readStartElement", e);
+ throw new Error("readStartElement", e);
}
};
@@ -371,7 +371,7 @@
return false;
}
else{
- throw new Exception("SHOULD BE STRING OR NUMBER");
+ throw new Error("SHOULD BE STRING OR NUMBER");
}
}
//returns Long
@@ -425,7 +425,7 @@
this.offset = previousOffset;
} catch ( e) {
Log.logStackTrace(Log.FAC_ENCODING, Level.WARNING, e);
- throw new Exception("Cannot reset stream! " + e.getMessage(), e);
+ throw new Error("Cannot reset stream! " + e.getMessage(), e);
}
}
return decodedTag;
@@ -767,7 +767,7 @@
//}
//catch (e) {
- //throw new Exception("Cannot parse " + startTag + ": " + strVal);
+ //throw new Error("Cannot parse " + startTag + ": " + strVal);
//}
return parseInt(strVal);
diff --git a/js/encoding/BinaryXMLEncoder.js b/js/encoding/BinaryXMLEncoder.js
index 16759b1..7404802 100644
--- a/js/encoding/BinaryXMLEncoder.js
+++ b/js/encoding/BinaryXMLEncoder.js
@@ -207,14 +207,14 @@
if(LOG>4) console.log('OFFSET IS ' + this.offset );
if ((type > XML_UDATA) || (type < 0) || (val < 0)) {
- throw new Exception("Tag and value must be positive, and tag valid.");
+ throw new Error("Tag and value must be positive, and tag valid.");
}
// Encode backwards. Calculate how many bytes we need:
var numEncodingBytes = this.numEncodingBytes(val);
if ((this.offset + numEncodingBytes) > buf.length) {
- throw new Exception("Buffer space of " + (buf.length-this.offset) +
+ throw new Error("Buffer space of " + (buf.length-this.offset) +
" bytes insufficient to hold " +
numEncodingBytes + " of encoded type and value.");
}
@@ -239,7 +239,7 @@
--i;
}
if (val != 0) {
- throw new Exception( "This should not happen: miscalculated encoding");
+ throw new Error( "This should not happen: miscalculated encoding");
//Log.warning(Log.FAC_ENCODING, "This should not happen: miscalculated encoding length, have " + val + " left.");
}
this.offset+= numEncodingBytes;