Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Commit 4bb431f

Browse files
authored
Fix mocktracer exception handling. (#118)
1 parent 597b0fa commit 4bb431f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

mocktracer/src/mock_span_context.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define OPENTRACING_MOCKTRACER_SPAN_CONTEXT_H
33

44
#include <opentracing/mocktracer/tracer.h>
5+
#include <exception>
56
#include <mutex>
67
#include <string>
78
#include "propagation.h"
@@ -30,12 +31,16 @@ class MockSpanContext : public SpanContext {
3031
std::function<bool(const std::string& key, const std::string& value)> f)
3132
const override;
3233

33-
std::string ToTraceID() const noexcept override {
34+
std::string ToTraceID() const noexcept override try {
3435
return std::to_string(data_.trace_id);
36+
} catch (const std::exception& /*e*/) {
37+
return {};
3538
}
3639

37-
std::string ToSpanID() const noexcept override {
40+
std::string ToSpanID() const noexcept override try {
3841
return std::to_string(data_.span_id);
42+
} catch (const std::exception& /*e*/) {
43+
return {};
3944
}
4045

4146
uint64_t trace_id() const noexcept { return data_.trace_id; }

0 commit comments

Comments
 (0)