Upgraded the severity of some warnings to errors and cleaned up internal API error adding
parent
cb6f88c6bb
commit
f9d88b4743
|
|
@ -216,12 +216,7 @@ APIError::Severity APIError::SeverityForType(ErrorType type) {
|
|||
switch(type) {
|
||||
// API Warnings
|
||||
case OutputTruncated:
|
||||
case DeviceCurrentlyOpen:
|
||||
case DeviceCurrentlyClosed:
|
||||
case DeviceCurrentlyOnline:
|
||||
case DeviceCurrentlyOffline:
|
||||
case DeviceCurrentlyPolling:
|
||||
case DeviceNotCurrentlyPolling:
|
||||
|
||||
// Device Warnings
|
||||
case PollingMessageOverflow:
|
||||
case DeviceFirmwareOutOfDate:
|
||||
|
|
@ -240,6 +235,12 @@ APIError::Severity APIError::SeverityForType(ErrorType type) {
|
|||
case MessageMaxLengthExceeded:
|
||||
|
||||
// Device Errors
|
||||
case DeviceCurrentlyOpen:
|
||||
case DeviceCurrentlyClosed:
|
||||
case DeviceCurrentlyOnline:
|
||||
case DeviceCurrentlyOffline:
|
||||
case DeviceCurrentlyPolling:
|
||||
case DeviceNotCurrentlyPolling:
|
||||
case NoSerialNumber:
|
||||
case IncorrectSerialNumber:
|
||||
case SettingsReadError:
|
||||
|
|
|
|||
|
|
@ -36,13 +36,14 @@ public:
|
|||
}
|
||||
void add(APIError::ErrorType type) {
|
||||
std::lock_guard<std::mutex> lk(mutex);
|
||||
add_internal(type);
|
||||
add_internal(APIError::APIError(type));
|
||||
}
|
||||
void add(APIError::ErrorType type, const Device* forDevice) {
|
||||
std::lock_guard<std::mutex> lk(mutex);
|
||||
add_internal(type, forDevice);
|
||||
add_internal(APIError::APIError(type, forDevice));
|
||||
}
|
||||
|
||||
|
||||
void discard(ErrorFilter filter = ErrorFilter());
|
||||
|
||||
void setErrorLimit(size_t newLimit) {
|
||||
|
|
@ -92,40 +93,6 @@ private:
|
|||
errors.push_back(error);
|
||||
}
|
||||
}
|
||||
void add_internal(APIError::ErrorType type) {
|
||||
// Ensure the error list is at most exactly full (size of errorLimit - 1, leaving room for a potential APIError::TooManyErrors)
|
||||
enforceLimit();
|
||||
|
||||
// We are exactly full, either because the list was truncated or because we were simply full before
|
||||
if(errors.size() == errorLimit - 1) {
|
||||
// If the error is worth adding
|
||||
if(APIError::SeverityForType(type) >= lowestCurrentSeverity()) {
|
||||
discardLeastSevere(1);
|
||||
errors.emplace_back(type);
|
||||
}
|
||||
|
||||
errors.push_back(APIError(APIError::TooManyErrors));
|
||||
} else {
|
||||
errors.emplace_back(type);
|
||||
}
|
||||
}
|
||||
void add_internal(APIError::ErrorType type, const Device* forDevice) {
|
||||
// Ensure the error list is at most exactly full (size of errorLimit - 1, leaving room for a potential APIError::TooManyErrors)
|
||||
enforceLimit();
|
||||
|
||||
// We are exactly full, either because the list was truncated or because we were simply full before
|
||||
if(errors.size() == errorLimit - 1) {
|
||||
// If the error is worth adding
|
||||
if(APIError::SeverityForType(type) >= lowestCurrentSeverity()) {
|
||||
discardLeastSevere(1);
|
||||
errors.emplace_back(type);
|
||||
}
|
||||
|
||||
errors.push_back(APIError(APIError::TooManyErrors));
|
||||
} else {
|
||||
errors.emplace_back(type, forDevice);
|
||||
}
|
||||
}
|
||||
|
||||
bool enforceLimit(); // Returns whether the limit enforcement resulted in an overflow
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue