cpp-common/bt2c: optionally log and append errors in `dataFromFile()`
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 25 Apr 2024 14:57:24 +0000 (14:57 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 4 Sep 2024 19:05:14 +0000 (15:05 -0400)
commit0f781e0b2c6b88ec2b4db7cbd288f31f1e7515fb
tree6ebd8b86701ba946fb996c567689b260d2903806
parent79186dfaa4a468bcd8a38c7ac3162e651eaee823
cpp-common/bt2c: optionally log and append errors in `dataFromFile()`

For some callers, a `dataFromFile()` error (`NoSuchFileOrDirectoryError`
typically) may be fatal, in which case it would be appropriate to log an
error and append an error cause.  For others callers, it might not be
fatal, they just want to catch the exception and carry on.

To accomodate this, pass a logger to `dataFromFile()` and add a
`fatalError` boolean parameter.  Log an error and append an error cause
on error if `fatalError` is true.  Otherwise, log at the debug level.

Change-Id: Id32639b16a928195bc430c1a2ce7671ced2ad43b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12738
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/cpp-common/bt2c/file-utils.cpp
src/cpp-common/bt2c/file-utils.hpp
This page took 0.024001 seconds and 4 git commands to generate.