mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 12:38:20 +00:00
Change threading formatter errors to warnings.
This change standardizes threading formatter error handling and moves the remaining error calls to be warnings instead. This is in line with already existing code - in most cases warnings were raised, only a few cases raised errors. These cases do not differ significantly from other cases in which warnings are raised. This also fixes GH-692, in which misformatted lines prevent future file parsing. This commit also moves the FailWarn method that is used by both the config and the ascii reader up to the ReaderBackend. Furthermore it makes the Warning method of ReaderBackend respect the warning suppression that is introduced by the FailWarn method.
This commit is contained in:
parent
5171f25e3a
commit
deaab42187
12 changed files with 90 additions and 70 deletions
|
@ -138,7 +138,7 @@ public:
|
|||
/**
|
||||
* One-time initialization of the reader to define the input source.
|
||||
*
|
||||
* @param @param info Meta information for the writer.
|
||||
* @param info Meta information for the writer.
|
||||
*
|
||||
* @param num_fields Number of fields contained in \a fields.
|
||||
*
|
||||
|
@ -184,11 +184,34 @@ public:
|
|||
*/
|
||||
int NumFields() const { return num_fields; }
|
||||
|
||||
/**
|
||||
* Convenience function that calls Warning or Error, depending on the
|
||||
* is_error parameter. In case of a warning, setting suppress_future to
|
||||
* true will suppress all future warnings until StopWarningSuppression()
|
||||
* is called.
|
||||
*
|
||||
* @param is_error If set to true, an error is generated. Else a warning
|
||||
* is generate.
|
||||
*
|
||||
* @param msg The error/warning message.
|
||||
*
|
||||
* @param suppress_future If set to true, future warnings are suppressed
|
||||
* until StopWarningSuppression is called.
|
||||
*/
|
||||
void FailWarn(bool is_error, const char *msg, bool suppress_future = false);
|
||||
|
||||
inline void StopWarningSuppression() { suppress_warnings = false; };
|
||||
|
||||
// Overridden from MsgThread.
|
||||
bool OnHeartbeat(double network_time, double current_time) override;
|
||||
bool OnFinish(double network_time) override;
|
||||
|
||||
void Info(const char* msg) override;
|
||||
|
||||
/**
|
||||
* Reports a warning in the child thread. For input readers, warning suppression
|
||||
* that is caused by calling FailWarn() is respected by the Warning function.
|
||||
*/
|
||||
void Warning(const char* msg) override;
|
||||
|
||||
/**
|
||||
|
@ -348,6 +371,9 @@ private:
|
|||
const threading::Field* const * fields; // raw mapping
|
||||
|
||||
bool disabled;
|
||||
// this is an internal indicator in case the read is currently in a failed state
|
||||
// it's used to suppress duplicate error messages.
|
||||
bool suppress_warnings = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue