Skip to content
Snippets Groups Projects
Verified Commit e2e6e76f authored by Denis Smirnov's avatar Denis Smirnov
Browse files

feat: convert tarantool errors into sbroad ones

parent c6961c92
No related branches found
No related tags found
1 merge request!1414sbroad import
use serde::Serialize; use serde::Serialize;
use std::fmt; use std::fmt;
use tarantool::error::Error;
use tarantool::transaction::TransactionError; use tarantool::transaction::TransactionError;
const DO_SKIP: &str = "do skip"; const DO_SKIP: &str = "do skip";
...@@ -115,6 +116,8 @@ pub enum Entity { ...@@ -115,6 +116,8 @@ pub enum Entity {
SyntaxPlan, SyntaxPlan,
/// corresponds to struct Table /// corresponds to struct Table
Table, Table,
/// corresponds to struct Tarantool
Tarantool,
/// corresponds to struct Target /// corresponds to struct Target
Target, Target,
/// tarantool transaction /// tarantool transaction
...@@ -192,6 +195,7 @@ impl fmt::Display for Entity { ...@@ -192,6 +195,7 @@ impl fmt::Display for Entity {
Entity::SyntaxNodes => "syntax nodes".to_string(), Entity::SyntaxNodes => "syntax nodes".to_string(),
Entity::SyntaxPlan => "syntax plan".to_string(), Entity::SyntaxPlan => "syntax plan".to_string(),
Entity::Table => "table".to_string(), Entity::Table => "table".to_string(),
Entity::Tarantool => "tarantool".to_string(),
Entity::Target => "target".to_string(), Entity::Target => "target".to_string(),
Entity::Transaction => "transaction".to_string(), Entity::Transaction => "transaction".to_string(),
Entity::Tuple => "tuple".to_string(), Entity::Tuple => "tuple".to_string(),
...@@ -341,3 +345,13 @@ impl<E: fmt::Debug> From<TransactionError<E>> for SbroadError { ...@@ -341,3 +345,13 @@ impl<E: fmt::Debug> From<TransactionError<E>> for SbroadError {
) )
} }
} }
impl From<Error> for SbroadError {
fn from(error: Error) -> Self {
SbroadError::FailedTo(
Action::Create,
Some(Entity::Tarantool),
format!("{error:?}"),
)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment