1// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
23use thiserror::Error;
45/// The error types for prometheus.
6#[derive(Debug, Error)]
7pub enum Error {
8/// A duplicate metric collector has already been registered.
9#[error("Duplicate metrics collector registration attempted")]
10AlreadyReg,
11/// The label cardinality was inconsistent.
12#[error("Inconsistent label cardinality, expect {expect} label values, but got {got}")]
13InconsistentCardinality {
14/// The expected number of labels.
15expect: usize,
16/// The actual number of labels.
17got: usize,
18 },
19/// An error message which is only a string.
20#[error("Error: {0}")]
21Msg(String),
22/// An error containing a [`std::io::Error`].
23#[error("Io error: {0}")]
24Io(#[from] std::io::Error),
25/// An error containing a [`protobuf::error::ProtobufError`].
26#[cfg(feature = "protobuf")]
27 #[error("Protobuf error: {0}")]
28Protobuf(#[from] protobuf::error::ProtobufError),
29}
3031/// A specialized Result type for prometheus.
32pub type Result<T> = std::result::Result<T, Error>;