Skip to content

Commit fb7bf47

Browse files
Errata: Update comments and documentation.
1 parent 9bee8ce commit fb7bf47

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

Diff for: code/include/swoc/Errata.h

+17
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ class Errata {
226226
*
227227
* The error code is set to the default.
228228
* @a text is localized to @a this and does not need to be persistent.
229+
* The severity is updated to @a severity if the latter is more severe.
229230
*/
230231
self_type &note(Severity severity, std::string_view text);
231232

@@ -254,6 +255,8 @@ class Errata {
254255
* This is a unified interface for other fixed text @c note methods which all forward to this
255256
* method. If @a severity does not have a value then the annotation is never filtered.
256257
*
258+
* The severity is updated to @a severity if the latter is set and more severe.
259+
*
257260
* @see FILTER_SEVERITY
258261
*/
259262
self_type &note_s(std::optional<Severity> severity, std::string_view text);
@@ -280,6 +283,8 @@ class Errata {
280283
* @param fmt Format string (@c BufferWriter style).
281284
* @param args Arguments for values in @a fmt.
282285
* @return A reference to this object.
286+
*
287+
* The severity is updated to @a severity if the latter is more severe.
283288
*/
284289
template <typename... Args> self_type &note(Severity severity, std::string_view fmt, Args &&... args);
285290

@@ -291,6 +296,8 @@ class Errata {
291296
*
292297
* This is intended for use by external "helper" methods that pass their own arguments to this
293298
* using @c forward_as_tuple.
299+
*
300+
* The severity is updated to @a severity if the latter is more severe.
294301
*/
295302
template <typename... Args> self_type &note_v(Severity severity, std::string_view fmt, std::tuple<Args...> const &args);
296303

@@ -300,6 +307,8 @@ class Errata {
300307
* @param args Arguments for values in @a fmt.
301308
* @return A reference to this object.
302309
*
310+
* The severity is updated to @a severity if the latter is set and more severe.
311+
*
303312
* This the effective implementation method for all variadic styles of the @a note method.
304313
*/
305314
template <typename... Args>
@@ -405,6 +414,9 @@ class Errata {
405414
/// The code for the top message.
406415
code_type const &code() const;
407416

417+
/// Set the @a code for @a this.
418+
self_type & assign(code_type code);
419+
408420
/// Number of messages in the errata.
409421
size_t length() const;
410422

@@ -916,6 +928,11 @@ Errata::code() const -> code_type const & {
916928
return this->empty() ? DEFAULT_CODE : _data->_code;
917929
}
918930

931+
inline auto Errata::assign(code_type code) -> self_type & {
932+
this->data()->_code = code;
933+
return *this;
934+
}
935+
919936
inline auto
920937
Errata::severity() const -> Severity {
921938
return _data ? _data->_severity : DEFAULT_SEVERITY;

Diff for: doc/code/Errata.en.rst

+8-7
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,16 @@ The initialization is done in :code:`test_Errata_init` which is called from :cod
119119
120120
If there is no external initialization, then there are three levels of severity 0..2 with
121121
the names "Info", "Warning", and "Error". The default severity is "Error" (2) with a failure threshold
122-
of 2.
122+
of 2 ("Error").
123123

124124
By default annotations do not have a severity, that is a property of the :code:`Errata`. However a
125-
severity can be added to an annotation. This has no effect on the severity of the :code:`Errata` and
126-
is intended purely for display and filtering. The latter can be done by adjusting the value of
127-
:code:`swoc::Errata::FILTER_SEVERITY`. If a severity is provided with an annotation (via some variant
128-
of the :code:`note` method) then this is checked against :code:`FILTER_SEVERITY` and if it is less
129-
than that the annotation is not added. This enables an application to dynamically control the
130-
verbosity of errors without changing how they are generated.
125+
severity can be added to an annotation. If this is done the the severity of the :code:`Errata` is
126+
updated to that severity if it is larger (more severe) than the current severity. Annotations can be
127+
filtered by adjusting the value of :code:`swoc::Errata::FILTER_SEVERITY`. If a severity is provided
128+
with an annotation (via some variant of the :code:`note` method) then this is checked against
129+
:code:`FILTER_SEVERITY` and if it is less than that the annotation is not added. This enables an
130+
application to dynamically control the verbosity of errors without changing how they are generated.
131+
The :code:`Errata` serverity is updated as appropriate even if the annotation is discarded.
131132

132133
Examples
133134
========

0 commit comments

Comments
 (0)