summaryrefslogtreecommitdiffstats
path: root/src/tracer_factory.cpp
blob: 8958310a686d81d3064c64b635c2c7c9dcaac85a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <opentracing/tracer_factory.h>
#include <opentracing/version.h>

namespace opentracing {
BEGIN_OPENTRACING_ABI_NAMESPACE
namespace {
class TracerFactoryErrorCategory : public std::error_category {
 public:
  TracerFactoryErrorCategory() {}

  const char* name() const noexcept override {
    return "OpenTracingTracerFactoryError";
  }

  std::error_condition default_error_condition(int code) const
      noexcept override {
    if (code == configuration_parse_error.value()) {
      return std::make_error_condition(std::errc::invalid_argument);
    }
    if (code == invalid_configuration_error.value()) {
      return std::make_error_condition(std::errc::invalid_argument);
    }
    return std::error_condition(code, *this);
  }

  std::string message(int code) const override {
    if (code == configuration_parse_error.value()) {
      return "opentracing: failed to parse configuration";
    }
    if (code == invalid_configuration_error.value()) {
      return "opentracing: invalid configuration";
    }
    return "opentracing: unknown tracer factory error";
  }
};
}  // anonymous namespace

const std::error_category& tracer_factory_error_category() {
  static const TracerFactoryErrorCategory error_category;
  return error_category;
}

END_OPENTRACING_ABI_NAMESPACE
}  // namespace opentracing