exceptions: Make Tlv::Error a base class for all packet-processing exceptions
This commit also includes a number of code style fixes.
Change-Id: I44f83915e733b43d5f43b4266902c8262e928d91
Refs: #1528
diff --git a/src/security/conf/checker.hpp b/src/security/conf/checker.hpp
index 72ae726..6955dfe 100644
--- a/src/security/conf/checker.hpp
+++ b/src/security/conf/checker.hpp
@@ -101,16 +101,16 @@
interestName[INTEREST_SIG_VALUE].blockFromValue());
return check(interest, signature, onValidated, onValidationFailed);
}
- catch (const Tlv::Error& e)
- {
- onValidationFailed(interest.shared_from_this(), "Cannot decode signature related TLVs");
- return -1;
- }
- catch (const Signature::Error& e)
+ catch (Signature::Error& e)
{
onValidationFailed(interest.shared_from_this(), "Invalid signature");
return -1;
}
+ catch (Tlv::Error& e)
+ {
+ onValidationFailed(interest.shared_from_this(), "Cannot decode signature related TLVs");
+ return -1;
+ }
}
private:
@@ -147,7 +147,7 @@
return -1;
}
}
- catch (const SignatureSha256WithRsa::Error& e)
+ catch (SignatureSha256WithRsa::Error& e)
{
onValidationFailed(packet.shared_from_this(),
"Cannot decode Sha256WithRsa signature!");
@@ -221,16 +221,16 @@
interestName[INTEREST_SIG_VALUE].blockFromValue());
return check(interest, signature, onValidated, onValidationFailed);
}
- catch (const Tlv::Error& e)
- {
- onValidationFailed(interest.shared_from_this(), "Cannot decode signature related TLVs");
- return -1;
- }
- catch (const Signature::Error& e)
+ catch (Signature::Error& e)
{
onValidationFailed(interest.shared_from_this(), "Invalid signature");
return -1;
}
+ catch (Tlv::Error& e)
+ {
+ onValidationFailed(interest.shared_from_this(), "Cannot decode signature related TLVs");
+ return -1;
+ }
}
private:
@@ -280,13 +280,13 @@
return -1;
}
}
- catch (const KeyLocator::Error& e)
+ catch (KeyLocator::Error& e)
{
onValidationFailed(packet.shared_from_this(),
"KeyLocator does not have name!");
return -1;
}
- catch (const SignatureSha256WithRsa::Error& e)
+ catch (SignatureSha256WithRsa::Error& e)
{
onValidationFailed(packet.shared_from_this(),
"Cannot decode signature!");
diff --git a/src/security/conf/filter.hpp b/src/security/conf/filter.hpp
index 7d5b833..4145222 100644
--- a/src/security/conf/filter.hpp
+++ b/src/security/conf/filter.hpp
@@ -207,7 +207,7 @@
{
return shared_ptr<RegexNameFilter>(new RegexNameFilter(regexString));
}
- catch (const Regex::Error& e)
+ catch (Regex::Error& e)
{
throw Error("Wrong filter.regex: " + regexString);
}
diff --git a/src/security/conf/key-locator-checker.hpp b/src/security/conf/key-locator-checker.hpp
index 5785c59..e040d80 100644
--- a/src/security/conf/key-locator-checker.hpp
+++ b/src/security/conf/key-locator-checker.hpp
@@ -107,7 +107,7 @@
failInfo = "KeyLocatorChecker failed!";
return false;
}
- catch (const KeyLocator::Error& e)
+ catch (KeyLocator::Error& e)
{
failInfo = "KeyLocator does not have name";
return false;
@@ -141,7 +141,7 @@
failInfo = "KeyLocatorChecker failed!";
return false;
}
- catch (const KeyLocator::Error& e)
+ catch (KeyLocator::Error& e)
{
failInfo = "KeyLocator does not have name";
return false;
@@ -182,7 +182,7 @@
failInfo = "KeyLocatorChecker failed!";
return false;
}
- catch (const KeyLocator::Error& e)
+ catch (KeyLocator::Error& e)
{
failInfo = "KeyLocator does not have name";
return false;
@@ -277,7 +277,7 @@
return shared_ptr<RegexKeyLocatorNameChecker>
(new RegexKeyLocatorNameChecker(regexString));
}
- catch (const Regex::Error& e)
+ catch (Regex::Error& e)
{
throw Error("Invalid checker.key-locator.regex: " + regexString);
}
@@ -344,7 +344,7 @@
kRegex, kExpand,
relation));
}
- catch (const Regex::Error& e)
+ catch (Regex::Error& e)
{
throw Error("Invalid regex for key-locator.hyper-relation");
}