Skip to content

Commit

Permalink
use strum macro
Browse files Browse the repository at this point in the history
  • Loading branch information
fuyufjh committed Mar 8, 2024
1 parent 4118624 commit 0b8b22a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 30 deletions.
32 changes: 20 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ serde_with = "3"
smallbitset = "0.7.1"
speedate = "0.13.0"
static_assertions = "1"
strum = "0.25"
strum = "0.26"
strum_macros = "0.26"
sysinfo = { version = "0.30", default-features = false }
thiserror = "1"
Expand Down
8 changes: 6 additions & 2 deletions src/connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ rdkafka = { workspace = true, features = [
"gssapi",
"zstd",
] }
redis = { version = "0.24.0", features = ["aio","tokio-comp","async-std-comp"] }
redis = { version = "0.24.0", features = [
"aio",
"tokio-comp",
"async-std-comp",
] }
regex = "1.4"
reqwest = { version = "0.11", features = ["json"] }
risingwave_common = { workspace = true }
Expand All @@ -120,7 +124,7 @@ serde_derive = "1"
serde_json = "1"
serde_with = { version = "3", features = ["json"] }
simd-json = "0.13.3"
strum = "0.25"
strum = "0.26"
strum_macros = "0.26"
tempfile = "3"
thiserror = "1"
Expand Down
2 changes: 2 additions & 0 deletions src/stream/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ rw_futures_util = { workspace = true }
serde_json = "1"
smallvec = "1"
static_assertions = "1"
strum = "0.26"
strum_macros = "0.26"
thiserror = "1"
thiserror-ext = { workspace = true }
tokio = { version = "0.2", package = "madsim-tokio", features = [
Expand Down
21 changes: 6 additions & 15 deletions src/stream/src/executor/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::convert::AsRef;

use risingwave_common::array::ArrayError;
use risingwave_common::error::{BoxedError, NotImplemented};
use risingwave_common::util::value_encoding::error::ValueEncodingError;
Expand All @@ -22,6 +24,7 @@ use risingwave_expr::ExprError;
use risingwave_pb::PbFieldNotFound;
use risingwave_rpc_client::error::RpcError;
use risingwave_storage::error::StorageError;
use strum_macros::AsRefStr;

use super::Barrier;

Expand All @@ -31,6 +34,7 @@ pub type StreamExecutorResult<T> = std::result::Result<T, StreamExecutorError>;
/// The error type for streaming executors.
#[derive(thiserror::Error, Debug, thiserror_ext::Box, thiserror_ext::Construct)]
#[thiserror_ext(newtype(name = StreamExecutorError, backtrace, report_debug))]
#[derive(AsRefStr)]
pub enum ErrorKind {
#[error("Storage error: {0}")]
Storage(
Expand Down Expand Up @@ -141,21 +145,8 @@ impl From<String> for StreamExecutorError {
}

impl StreamExecutorError {
pub fn variant_name(&self) -> &'static str {
match self.0.inner() {
ErrorKind::Storage(_) => "StorageError",
ErrorKind::ArrayError(_) => "ArrayError",
ErrorKind::ExprError(_) => "ExprError",
ErrorKind::SerdeError(_) => "SerdeError",
ErrorKind::SinkError(_) => "SinkError",
ErrorKind::RpcError(_) => "RpcError",
ErrorKind::ChannelClosed(_) => "ChannelClosed",
ErrorKind::AlignBarrier(_, _) => "AlignBarrier",
ErrorKind::ConnectorError(_) => "ConnectorError",
ErrorKind::DmlError(_) => "DmlError",
ErrorKind::NotImplemented(_) => "NotImplemented",
ErrorKind::Internal(_) => "Internal",
}
pub fn variant_name(&self) -> &str {
self.0.inner().as_ref()
}
}

Expand Down

0 comments on commit 0b8b22a

Please sign in to comment.