diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:44:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:44:33 +0000 |
commit | b196c6498d22e47bb9d0da0153068ec54eac7956 (patch) | |
tree | 1a994a492581e93224a7ee6455f5d4e9d2ec8e59 /src/propagation.cpp | |
parent | Initial commit. (diff) | |
download | opentracing-cpp-upstream/1.6.0.tar.xz opentracing-cpp-upstream/1.6.0.zip |
Adding upstream version 1.6.0.upstream/1.6.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/propagation.cpp')
-rw-r--r-- | src/propagation.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/propagation.cpp b/src/propagation.cpp new file mode 100644 index 0000000..56f8394 --- /dev/null +++ b/src/propagation.cpp @@ -0,0 +1,63 @@ +#include <opentracing/propagation.h> + +namespace opentracing { +BEGIN_OPENTRACING_ABI_NAMESPACE +namespace { +class PropagationErrorCategory : public std::error_category { + public: + // Needed to fix bug in macOS build + // (https://travis-ci.org/isaachier/hunter/jobs/281868518). + // See https://stackoverflow.com/a/7411708/1930331 for justification. + PropagationErrorCategory() {} + + const char* name() const noexcept override { + return "OpenTracingPropagationError"; + } + + std::error_condition default_error_condition(int code) const + noexcept override { + if (code == invalid_span_context_error.value()) { + return std::make_error_condition(std::errc::not_supported); + } + if (code == invalid_carrier_error.value()) { + return std::make_error_condition(std::errc::invalid_argument); + } + if (code == span_context_corrupted_error.value()) { + return std::make_error_condition(std::errc::invalid_argument); + } + if (code == key_not_found_error.value()) { + return std::make_error_condition(std::errc::invalid_argument); + } + if (code == lookup_key_not_supported_error.value()) { + return std::make_error_condition(std::errc::not_supported); + } + return std::error_condition(code, *this); + } + + std::string message(int code) const override { + if (code == invalid_span_context_error.value()) { + return "opentracing: SpanContext type incompatible with tracer"; + } + if (code == invalid_carrier_error.value()) { + return "opentracing: Invalid Inject/Extract carrier"; + } + if (code == span_context_corrupted_error.value()) { + return "opentracing: SpanContext data corrupted in Extract carrier"; + } + if (code == key_not_found_error.value()) { + return "opentracing: SpanContext key not found"; + } + if (code == lookup_key_not_supported_error.value()) { + return "opentracing: Lookup for the given key is not supported"; + } + return "opentracing: unknown propagation error"; + } +}; +} // anonymous namespace + +const std::error_category& propagation_error_category() { + static const PropagationErrorCategory error_category; + return error_category; +} +END_OPENTRACING_ABI_NAMESPACE +} // namespace opentracing |