aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuliano Procida <gprocida@google.com>2023-12-12 17:43:58 +0000
committerGiuliano Procida <gprocida@google.com>2023-12-13 11:25:55 +0000
commit20fb84fcd511d8f92e27444f4357334d5d55d05e (patch)
treea2f39f68b309900a00c55261798b45836fb54eac
parent4d5423fcffc43ed2969742f6d75a4c437ead3578 (diff)
downloadstg-20fb84fcd511d8f92e27444f4357334d5d55d05e.tar.gz
input: add file context to exceptions
``` $ stg --types --elf libRS.so found conflicting interface type: std::__1::allocator::const_pointer processing file 'libRS.so' ``` PiperOrigin-RevId: 590237752 Change-Id: I3563cbf9bd0408808a2e1e788cd1c624d2695f47
-rw-r--r--input.cc25
1 files changed, 22 insertions, 3 deletions
diff --git a/input.cc b/input.cc
index c396b47..f30cdca 100644
--- a/input.cc
+++ b/input.cc
@@ -20,10 +20,12 @@
#include "input.h"
#include <memory>
+#include <sstream>
#include "abigail_reader.h"
#include "btf_reader.h"
#include "elf_reader.h"
+#include "error.h"
#include "filter.h"
#include "graph.h"
#include "metrics.h"
@@ -32,9 +34,11 @@
namespace stg {
-Id Read(Graph& graph, InputFormat format, const char* input,
- ReadOptions options, const std::unique_ptr<Filter>& file_filter,
- Metrics& metrics) {
+namespace {
+
+Id ReadInternal(Graph& graph, InputFormat format, const char* input,
+ ReadOptions options, const std::unique_ptr<Filter>& file_filter,
+ Metrics& metrics) {
switch (format) {
case InputFormat::ABI: {
Time read(metrics, "read ABI");
@@ -55,4 +59,19 @@ Id Read(Graph& graph, InputFormat format, const char* input,
}
}
+} // namespace
+
+Id Read(Graph& graph, InputFormat format, const char* input,
+ ReadOptions options, const std::unique_ptr<Filter>& file_filter,
+ Metrics& metrics) {
+ try {
+ return ReadInternal(graph, format, input, options, file_filter, metrics);
+ } catch (Exception& e) {
+ std::ostringstream os;
+ os << "processing file '" << input << '\'';
+ e.Add(os.str());
+ throw;
+ }
+}
+
} // namespace stg