Browse Source

Catch exception object by reference rather than value.

adeniz_1
Alban Deniz 1 year ago
parent
commit
778418941a
1 changed files with 16 additions and 16 deletions
  1. 16
    16
      SNFMulti.cpp

+ 16
- 16
SNFMulti.cpp View File

MyRulebase.logThisInfo( // Log our success. MyRulebase.logThisInfo( // Log our success.
snfReloadContext, snf_SUCCESS, "Success"); snfReloadContext, snf_SUCCESS, "Success");
} }
catch(snf_RulebaseHandler::IgnoreListError) { // If we get an IgnoreListError - say so.
catch(snf_RulebaseHandler::IgnoreListError&) { // If we get an IgnoreListError - say so.
MyRulebase.logThisError( MyRulebase.logThisError(
snfReloadContext, snf_ERROR_RULE_FILE, "IgnoreListError"); snfReloadContext, snf_ERROR_RULE_FILE, "IgnoreListError");
} }
catch(snf_RulebaseHandler::ConfigurationError) { // If we get a ConfigurationError - say so.
catch(snf_RulebaseHandler::ConfigurationError&) { // If we get a ConfigurationError - say so.
MyRulebase.logThisError( MyRulebase.logThisError(
snfReloadContext, snf_ERROR_RULE_FILE, "ConfigurationError"); snfReloadContext, snf_ERROR_RULE_FILE, "ConfigurationError");
} }
catch(snf_RulebaseHandler::FileError x) { // If we get a FileError - say so.
catch(snf_RulebaseHandler::FileError &x) { // If we get a FileError - say so.
MyRulebase.logThisError( MyRulebase.logThisError(
snfReloadContext, snf_ERROR_RULE_FILE, "FileError"); snfReloadContext, snf_ERROR_RULE_FILE, "FileError");
} }
catch(snf_RulebaseHandler::AuthenticationError x) { // If we get a Auth Error - say so.
catch(snf_RulebaseHandler::AuthenticationError &x) { // If we get a Auth Error - say so.
MyRulebase.logThisError( MyRulebase.logThisError(
snfReloadContext, snf_ERROR_RULE_AUTH, "AuthError"); snfReloadContext, snf_ERROR_RULE_AUTH, "AuthError");
} }
catch(snf_RulebaseHandler::Busy x) { // If we get a Busy Exception - say so.
catch(snf_RulebaseHandler::Busy &x) { // If we get a Busy Exception - say so.
MyRulebase.logThisError( MyRulebase.logThisError(
snfReloadContext, snf_ERROR_UNKNOWN, "BusyError"); snfReloadContext, snf_ERROR_UNKNOWN, "BusyError");
} }
catch(snf_RulebaseHandler::Panic x) { // If we get a Panic - say so.
catch(snf_RulebaseHandler::Panic &x) { // If we get a Panic - say so.
MyRulebase.logThisError( MyRulebase.logThisError(
snfReloadContext, snf_ERROR_UNKNOWN, "PanicError"); snfReloadContext, snf_ERROR_UNKNOWN, "PanicError");
} }
} }
} // If nothing threw, we're golden! } // If nothing threw, we're golden!


catch (TokenMatrix::BadFile) { // BadFile translates to FileError
catch (TokenMatrix::BadFile&) { // BadFile translates to FileError
throw FileError("_snf_LoadNewRulebase() TokenMatrix::BadFile"); throw FileError("_snf_LoadNewRulebase() TokenMatrix::BadFile");
} }
catch (TokenMatrix::BadMatrix) { // BadMatrix translates to AuthenticationError
catch (TokenMatrix::BadMatrix&) { // BadMatrix translates to AuthenticationError
throw AuthenticationError("_snf_LoadNewRulebase() TokenMatrix::BadMatrix"); throw AuthenticationError("_snf_LoadNewRulebase() TokenMatrix::BadMatrix");
} }
catch (TokenMatrix::BadAllocation) { // BadAllocation translates to AllocationError
catch (TokenMatrix::BadAllocation&) { // BadAllocation translates to AllocationError
throw AllocationError("_snf_LoadNewRulebase() TokenMatrix::BadAllocation"); throw AllocationError("_snf_LoadNewRulebase() TokenMatrix::BadAllocation");
} }
catch (TokenMatrix::OutOfRange) { // OutOfRange should never happen so PANIC!
catch (TokenMatrix::OutOfRange&) { // OutOfRange should never happen so PANIC!
throw Panic("_snf_LoadNewRulebase() TokenMatrix::OutOfRange"); throw Panic("_snf_LoadNewRulebase() TokenMatrix::OutOfRange");
} }
catch (exception e) {
catch (exception &e) {
throw; throw;
} }
catch (...) { // Something unpredicted happens? PANIC! catch (...) { // Something unpredicted happens? PANIC!
output.append(S.str()); output.append(S.str());
output.append("}"); output.append("}");
} }
catch(snfScanData::NoFreeIPScanRecords) {
catch(snfScanData::NoFreeIPScanRecords&) {
output = "{too_many}"; output = "{too_many}";
} }
catch(...) { catch(...) {
for(int a = 0; a < snf_ScanHorizon; a++) // the message through the filter for(int a = 0; a < snf_ScanHorizon; a++) // the message through the filter
MyScanData.FilteredData.push_back(xb=IZ.GetByte()); // chain into the FilteredData buffer. MyScanData.FilteredData.push_back(xb=IZ.GetByte()); // chain into the FilteredData buffer.
} // When we run out of data we will } // When we run out of data we will
catch(FilterChain::Empty) {} // get the Empty exception and stop.
catch(FilterChain::Empty&) {} // get the Empty exception and stop.


// Scan each byte in the file up to the horizon or the end of the message. // Scan each byte in the file up to the horizon or the end of the message.
// If something goes wrong, an exception will be thrown. // If something goes wrong, an exception will be thrown.


DebugInfo = "scanMessage() Scan Data Complete"; // If we panic, here we are. DebugInfo = "scanMessage() Scan Data Complete"; // If we panic, here we are.
} }
catch(EvaluationMatrix::BadAllocation) { // Check for bad allocation during scan.
catch(EvaluationMatrix::BadAllocation&) { // Check for bad allocation during scan.
throw AllocationError("EvaluationMatrix::BadAllocation"); throw AllocationError("EvaluationMatrix::BadAllocation");
} }
catch(EvaluationMatrix::MaxEvalsExceeded) { // Check for too many evaluators.
catch(EvaluationMatrix::MaxEvalsExceeded&) { // Check for too many evaluators.
throw MaxEvals("EvaluationMatrix::MaxEvalsExceeded"); throw MaxEvals("EvaluationMatrix::MaxEvalsExceeded");
} }
catch(EvaluationMatrix::OutOfRange) { // Check for out of range of (bad) matrix.
catch(EvaluationMatrix::OutOfRange&) { // Check for out of range of (bad) matrix.
throw BadMatrix("EvaluationMatrix::OutOfRange"); throw BadMatrix("EvaluationMatrix::OutOfRange");
} }
catch(exception& e) { // Some other known exception? catch(exception& e) { // Some other known exception?

Loading…
Cancel
Save