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

Commit

Permalink
Fix mocktracer exception handling. (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
rnburn authored Sep 18, 2019
1 parent 597b0fa commit 4bb431f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mocktracer/src/mock_span_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define OPENTRACING_MOCKTRACER_SPAN_CONTEXT_H

#include <opentracing/mocktracer/tracer.h>
#include <exception>
#include <mutex>
#include <string>
#include "propagation.h"
Expand Down Expand Up @@ -30,12 +31,16 @@ class MockSpanContext : public SpanContext {
std::function<bool(const std::string& key, const std::string& value)> f)
const override;

std::string ToTraceID() const noexcept override {
std::string ToTraceID() const noexcept override try {
return std::to_string(data_.trace_id);
} catch (const std::exception& /*e*/) {
return {};
}

std::string ToSpanID() const noexcept override {
std::string ToSpanID() const noexcept override try {
return std::to_string(data_.span_id);
} catch (const std::exception& /*e*/) {
return {};
}

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

0 comments on commit 4bb431f

Please sign in to comment.