mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Add error system
This commit is contained in:
+110
-24
@@ -7,6 +7,7 @@
|
||||
#include "icsneo/icsneoc.h"
|
||||
#include "icsneo/icsneocpp.h"
|
||||
#include "icsneo/platform/dynamiclib.h"
|
||||
#include "icsneo/api/errormanager.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
@@ -25,8 +26,10 @@ static std::map<devicehandle_t, std::vector<std::shared_ptr<Message>>> polledMes
|
||||
void icsneo_findAllDevices(neodevice_t* devices, size_t* count) {
|
||||
std::vector<std::shared_ptr<Device>> foundDevices = icsneo::FindAllDevices();
|
||||
|
||||
if(count == nullptr)
|
||||
if(count == nullptr) {
|
||||
ErrorManager::GetInstance().add(APIError::RequiredParameterNull);
|
||||
return;
|
||||
}
|
||||
|
||||
if(devices == nullptr) {
|
||||
*count = foundDevices.size();
|
||||
@@ -39,7 +42,7 @@ void icsneo_findAllDevices(neodevice_t* devices, size_t* count) {
|
||||
*count = foundDevices.size();
|
||||
size_t outputSize = *count;
|
||||
if(outputSize > inputSize) {
|
||||
// TODO an error should be returned that the data was truncated
|
||||
ErrorManager::GetInstance().add(APIError::OutputTruncated);
|
||||
outputSize = inputSize;
|
||||
}
|
||||
|
||||
@@ -54,9 +57,22 @@ void icsneo_freeUnconnectedDevices() {
|
||||
}
|
||||
|
||||
bool icsneo_serialNumToString(uint32_t num, char* str, size_t* count) {
|
||||
// TAG String copy function
|
||||
if(count == nullptr) {
|
||||
ErrorManager::GetInstance().add(APIError::RequiredParameterNull);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto result = Device::SerialNumToString(num);
|
||||
|
||||
if(str == nullptr) {
|
||||
*count = result.length() + 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(*count < result.length()) {
|
||||
*count = result.length() + 1; // This is how big of a buffer we need
|
||||
ErrorManager::GetInstance().add(APIError::BufferInsufficient);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -83,8 +99,10 @@ bool icsneo_isValidNeoDevice(const neodevice_t* device) {
|
||||
}
|
||||
|
||||
bool icsneo_openDevice(const neodevice_t* device) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!device->device->open())
|
||||
return false;
|
||||
@@ -104,8 +122,10 @@ bool icsneo_openDevice(const neodevice_t* device) {
|
||||
}
|
||||
|
||||
bool icsneo_closeDevice(const neodevice_t* device) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!device->device->close())
|
||||
return false;
|
||||
@@ -123,47 +143,61 @@ bool icsneo_closeDevice(const neodevice_t* device) {
|
||||
}
|
||||
|
||||
bool icsneo_goOnline(const neodevice_t* device) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
return device->device->goOnline();
|
||||
}
|
||||
|
||||
bool icsneo_goOffline(const neodevice_t* device) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
return device->device->goOffline();
|
||||
}
|
||||
|
||||
bool icsneo_isOnline(const neodevice_t* device) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
return device->device->isOnline();
|
||||
}
|
||||
|
||||
bool icsneo_enableMessagePolling(const neodevice_t* device) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
device->device->enableMessagePolling();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool icsneo_disableMessagePolling(const neodevice_t* device) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
return device->device->disableMessagePolling();
|
||||
}
|
||||
|
||||
bool icsneo_getMessages(const neodevice_t* device, neomessage_t* messages, size_t* items) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(items == nullptr)
|
||||
if(items == nullptr) {
|
||||
ErrorManager::GetInstance().add(APIError::RequiredParameterNull);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(messages == nullptr) {
|
||||
// A NULL value for messages means the user wants the current size of the buffer into items
|
||||
@@ -189,79 +223,117 @@ bool icsneo_getMessages(const neodevice_t* device, neomessage_t* messages, size_
|
||||
}
|
||||
|
||||
size_t icsneo_getPollingMessageLimit(const neodevice_t* device) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return device->device->getPollingMessageLimit();
|
||||
}
|
||||
|
||||
bool icsneo_setPollingMessageLimit(const neodevice_t* device, size_t newLimit) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
device->device->setPollingMessageLimit(newLimit);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool icsneo_getProductName(const neodevice_t* device, char* str, size_t* maxLength) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
// TAG String copy function
|
||||
if(maxLength == nullptr) {
|
||||
ErrorManager::GetInstance().add(APIError::RequiredParameterNull);
|
||||
return false;
|
||||
}
|
||||
|
||||
*maxLength = device->device->getType().toString().copy(str, *maxLength);
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string output = device->device->getType().toString();
|
||||
|
||||
if(str == nullptr) {
|
||||
*maxLength = output.length();
|
||||
return false;
|
||||
}
|
||||
|
||||
*maxLength = output.copy(str, *maxLength);
|
||||
str[*maxLength] = '\0';
|
||||
|
||||
if(output.length() > *maxLength)
|
||||
ErrorManager::GetInstance().add(APIError::OutputTruncated);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool icsneo_settingsRefresh(const neodevice_t* device) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
return device->device->settings->refresh();
|
||||
}
|
||||
|
||||
bool icsneo_settingsApply(const neodevice_t* device) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
return device->device->settings->apply();
|
||||
}
|
||||
|
||||
bool icsneo_settingsApplyTemporary(const neodevice_t* device) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
return device->device->settings->apply(true);
|
||||
}
|
||||
|
||||
bool icsneo_settingsApplyDefaults(const neodevice_t* device) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
return device->device->settings->applyDefaults();
|
||||
}
|
||||
|
||||
bool icsneo_settingsApplyDefaultsTemporary(const neodevice_t* device) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
return device->device->settings->applyDefaults(true);
|
||||
}
|
||||
|
||||
bool icsneo_setBaudrate(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
return device->device->settings->setBaudrateFor(netid, newBaudrate);
|
||||
}
|
||||
|
||||
bool icsneo_transmit(const neodevice_t* device, const neomessage_t* message) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
return device->device->transmit(CreateMessageFromNeoMessage(message));
|
||||
}
|
||||
|
||||
bool icsneo_transmitMessages(const neodevice_t* device, const neomessage_t* messages, size_t count) {
|
||||
// Transmit implements neodevice_t check so it is not needed here
|
||||
// TODO This can be implemented faster
|
||||
for(size_t i = 0; i < count; i++) {
|
||||
if(!icsneo_transmit(device, messages + i))
|
||||
@@ -271,10 +343,24 @@ bool icsneo_transmitMessages(const neodevice_t* device, const neomessage_t* mess
|
||||
}
|
||||
|
||||
bool icsneo_describeDevice(const neodevice_t* device, char* str, size_t* maxLength) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
// TAG String copy function
|
||||
if(maxLength == nullptr) {
|
||||
ErrorManager::GetInstance().add(APIError::RequiredParameterNull);
|
||||
return false;
|
||||
}
|
||||
|
||||
*maxLength = device->device->describe().copy(str, *maxLength);
|
||||
if(!icsneo_isValidNeoDevice(device)) {
|
||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string output = device->device->describe();
|
||||
|
||||
*maxLength = output.copy(str, *maxLength);
|
||||
str[*maxLength] = '\0';
|
||||
|
||||
if(output.length() > *maxLength)
|
||||
ErrorManager::GetInstance().add(APIError::OutputTruncated);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
#include "icsneo/api/error.h"
|
||||
#include "icsneo/device/device.h"
|
||||
#include <sstream>
|
||||
|
||||
using namespace icsneo;
|
||||
|
||||
APIError::APIError(ErrorType error) : errorStruct({}) {
|
||||
init(error);
|
||||
}
|
||||
|
||||
APIError::APIError(ErrorType error, const Device* forDevice) : errorStruct({}) {
|
||||
device = forDevice;
|
||||
serial = device->getSerial();
|
||||
errorStruct.serial[serial.copy(errorStruct.serial, sizeof(errorStruct.serial))] = '\0';
|
||||
|
||||
init(error);
|
||||
}
|
||||
|
||||
void APIError::init(ErrorType error) {
|
||||
timepoint = std::chrono::high_resolution_clock::now();
|
||||
errorStruct.description = DescriptionForType(error);
|
||||
errorStruct.errorNumber = (uint32_t)error;
|
||||
errorStruct.severity = (uint8_t)SeverityForType(error);
|
||||
errorStruct.timestamp = std::chrono::high_resolution_clock::to_time_t(timepoint);
|
||||
}
|
||||
|
||||
std::string APIError::describe() const noexcept {
|
||||
std::stringstream ss;
|
||||
if(device)
|
||||
ss << *device; // Makes use of device.describe()
|
||||
else
|
||||
ss << "API";
|
||||
ss << " Error: ";
|
||||
ss << getDescription();
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool APIError::isForDevice(std::string serial) const noexcept {
|
||||
if(!device || serial.length() == 0)
|
||||
return false;
|
||||
return device->getSerial() == serial;
|
||||
}
|
||||
|
||||
// API Errors
|
||||
static constexpr const char* ERROR_INVALID_NEODEVICE = "The provided neodevice_t object was invalid.";
|
||||
static constexpr const char* ERROR_REQUIRED_PARAMETER_NULL = "A required parameter was NULL.";
|
||||
static constexpr const char* ERROR_BUFFER_INSUFFICIENT = "The provided buffer was insufficient. No data was written.";
|
||||
static constexpr const char* ERROR_OUTPUT_TRUNCATED = "The output was too large for the provided buffer and has been truncated.";
|
||||
static constexpr const char* ERROR_PARAMETER_OUT_OF_RANGE = "A parameter was out of range.";
|
||||
|
||||
// Device Errors
|
||||
static constexpr const char* ERROR_POLLING_MESSAGE_OVERFLOW = "Too many messages have been recieved for the polling message buffer, some have been lost!";
|
||||
static constexpr const char* ERROR_NO_SERIAL_NUMBER = "Communication could not be established with the device. Perhaps it is not powered with 12 volts?";
|
||||
static constexpr const char* ERROR_INCORRECT_SERIAL_NUMBER = "The device did not return the expected serial number!";
|
||||
static constexpr const char* ERROR_SETTINGS_READ = "The device settings could not be read.";
|
||||
static constexpr const char* ERROR_SETTINGS_VERSION = "The settings version is incorrect, please update your firmware with neoVI Explorer.";
|
||||
static constexpr const char* ERROR_SETTINGS_LENGTH = "The settings length is incorrect, please update your firmware with neoVI Explorer.";
|
||||
static constexpr const char* ERROR_SETTINGS_CHECKSUM = "The settings checksum is incorrect, attempting to set defaults may remedy this issue.";
|
||||
static constexpr const char* ERROR_SETTINGS_NOT_AVAILABLE = "Settings are not available for this device.";
|
||||
|
||||
static constexpr const char* ERROR_TOO_MANY_ERRORS = "Too many errors have occurred. The list has been truncated.";
|
||||
static constexpr const char* ERROR_UNKNOWN = "An unknown internal error occurred.";
|
||||
static constexpr const char* ERROR_INVALID = "An invalid internal error occurred.";
|
||||
const char* APIError::DescriptionForType(ErrorType type) {
|
||||
switch(type) {
|
||||
// API Errors
|
||||
case InvalidNeoDevice:
|
||||
return ERROR_INVALID_NEODEVICE;
|
||||
case RequiredParameterNull:
|
||||
return ERROR_REQUIRED_PARAMETER_NULL;
|
||||
case BufferInsufficient:
|
||||
return ERROR_BUFFER_INSUFFICIENT;
|
||||
case OutputTruncated:
|
||||
return ERROR_OUTPUT_TRUNCATED;
|
||||
case ParameterOutOfRange:
|
||||
return ERROR_PARAMETER_OUT_OF_RANGE;
|
||||
|
||||
// Device Errors
|
||||
case PollingMessageOverflow:
|
||||
return ERROR_POLLING_MESSAGE_OVERFLOW;
|
||||
case NoSerialNumber:
|
||||
return ERROR_NO_SERIAL_NUMBER;
|
||||
case IncorrectSerialNumber:
|
||||
return ERROR_INCORRECT_SERIAL_NUMBER;
|
||||
case SettingsReadError:
|
||||
return ERROR_SETTINGS_READ;
|
||||
case SettingsVersionError:
|
||||
return ERROR_SETTINGS_VERSION;
|
||||
case SettingsLengthError:
|
||||
return ERROR_SETTINGS_LENGTH;
|
||||
case SettingsChecksumError:
|
||||
return ERROR_SETTINGS_CHECKSUM;
|
||||
case SettingsNotAvailable:
|
||||
return ERROR_SETTINGS_NOT_AVAILABLE;
|
||||
|
||||
// Other Errors
|
||||
case TooManyErrors:
|
||||
return ERROR_TOO_MANY_ERRORS;
|
||||
case Unknown:
|
||||
return ERROR_UNKNOWN;
|
||||
default:
|
||||
return ERROR_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
APIError::Severity APIError::SeverityForType(ErrorType type) {
|
||||
switch(type) {
|
||||
// API Warnings
|
||||
case OutputTruncated:
|
||||
// Device Warnings
|
||||
case PollingMessageOverflow:
|
||||
return Severity::Warning;
|
||||
|
||||
// API Errors
|
||||
case InvalidNeoDevice:
|
||||
case RequiredParameterNull:
|
||||
case BufferInsufficient:
|
||||
case ParameterOutOfRange:
|
||||
// Device Errors
|
||||
case NoSerialNumber:
|
||||
case IncorrectSerialNumber:
|
||||
case SettingsReadError:
|
||||
case SettingsVersionError:
|
||||
case SettingsLengthError:
|
||||
case SettingsChecksumError:
|
||||
case SettingsNotAvailable:
|
||||
// Other Errors
|
||||
case TooManyErrors:
|
||||
case Unknown:
|
||||
default:
|
||||
return Severity::Error;
|
||||
}
|
||||
}
|
||||
|
||||
bool ErrorFilter::match(const APIError& error) const noexcept {
|
||||
if(type != APIError::Any && type != error.getType())
|
||||
return false;
|
||||
|
||||
if(matchOnDevicePtr && !error.isForDevice(device))
|
||||
return false;
|
||||
|
||||
if(severity != APIError::Severity::Any && severity != error.getSeverity())
|
||||
return false;
|
||||
|
||||
if(serial.length() != 0 && !error.isForDevice(serial))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
#include "icsneo/api/errormanager.h"
|
||||
#include <memory>
|
||||
|
||||
using namespace icsneo;
|
||||
|
||||
static std::unique_ptr<ErrorManager> singleton;
|
||||
|
||||
ErrorManager& ErrorManager::GetInstance() {
|
||||
if(!singleton)
|
||||
singleton = std::unique_ptr<ErrorManager>(new ErrorManager());
|
||||
return *singleton.get();
|
||||
}
|
||||
|
||||
void ErrorManager::get(std::vector<APIError>& errorOutput, size_t max, ErrorFilter filter) {
|
||||
std::lock_guard<std::mutex> lk(mutex);
|
||||
|
||||
if(max == 0) // A limit of 0 indicates no limit
|
||||
max = (size_t)-1;
|
||||
|
||||
size_t count = 0;
|
||||
errorOutput.clear();
|
||||
auto it = errors.begin();
|
||||
while(it != errors.end()) {
|
||||
if(filter.match(*it)) {
|
||||
errorOutput.push_back(*it);
|
||||
errors.erase(it++);
|
||||
if(count++ >= max)
|
||||
break; // We now have as many written to output as we can
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ErrorManager::getOne(APIError& errorOutput, ErrorFilter filter) {
|
||||
std::vector<APIError> output;
|
||||
get(output, filter, 1);
|
||||
|
||||
if(output.size() == 0)
|
||||
return false;
|
||||
|
||||
errorOutput = output[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
void ErrorManager::discard(ErrorFilter filter) {
|
||||
std::lock_guard<std::mutex> lk(mutex);
|
||||
errors.remove_if([&filter](const APIError& error) {
|
||||
return filter.match(error);
|
||||
});
|
||||
}
|
||||
|
||||
size_t ErrorManager::count_internal(ErrorFilter filter) const {
|
||||
size_t ret = 0;
|
||||
for(auto& error : errors)
|
||||
if(filter.match(error))
|
||||
ret++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ErrorManager::beforeAddCheck(APIError::ErrorType type) {
|
||||
if(enforceLimit()) { // The enforceLimit will add the "TooManyErrors" error for us if necessary
|
||||
// We need to decide whether to add this error or drop it
|
||||
// We would have to remove something if we added this error
|
||||
if(APIError::SeverityForType(type) < lowestCurrentSeverity())
|
||||
return false; // Don't add this one, we are already full of higher priority items
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ErrorManager::enforceLimit() {
|
||||
if(errors.size() + 1 < errorLimit)
|
||||
return false;
|
||||
|
||||
bool hasTooManyWarningAlready = count_internal(ErrorFilter(APIError::TooManyErrors)) != 0;
|
||||
size_t amountToRemove = (errors.size() + (hasTooManyWarningAlready ? 0 : 1)) - errorLimit;
|
||||
|
||||
discardLeastSevere(amountToRemove);
|
||||
if(!hasTooManyWarningAlready)
|
||||
add_internal(APIError::TooManyErrors);
|
||||
return true;
|
||||
}
|
||||
|
||||
APIError::Severity ErrorManager::lowestCurrentSeverity() {
|
||||
if(errors.empty())
|
||||
return APIError::Severity(0);
|
||||
|
||||
APIError::Severity lowest = APIError::Severity::Error;
|
||||
auto it = errors.begin();
|
||||
while(it != errors.end()) {
|
||||
if((*it).getSeverity() < lowest)
|
||||
lowest = (*it).getSeverity();
|
||||
}
|
||||
return lowest;
|
||||
}
|
||||
|
||||
void ErrorManager::discardLeastSevere(size_t count) {
|
||||
if(count == 0)
|
||||
return;
|
||||
|
||||
ErrorFilter infoFilter(APIError::Severity::Info);
|
||||
auto it = errors.begin();
|
||||
while(it != errors.end()) {
|
||||
if(infoFilter.match(*it)) {
|
||||
errors.erase(it++);
|
||||
if(--count == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(count != 0) {
|
||||
ErrorFilter warningFilter(APIError::Severity::Warning);
|
||||
it = errors.begin();
|
||||
while(it != errors.end()) {
|
||||
if(warningFilter.match(*it)) {
|
||||
errors.erase(it++);
|
||||
if(--count == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(count != 0) {
|
||||
ErrorFilter warningFilter(APIError::Severity::Warning);
|
||||
it = errors.begin();
|
||||
while(it != errors.end()) {
|
||||
if(warningFilter.match(*it)) {
|
||||
errors.erase(it++);
|
||||
if(--count == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user