Skip to content

Commit

Permalink
Fix compatibility with the latest rust versions
Browse files Browse the repository at this point in the history
List of changes:
- Stop using "err-derive" crate and drop it from dependencies.
  Instead, use already utilized "thiserror" crate.
- Remove static links in some places as redundant.
  • Loading branch information
vponomaryov committed Dec 10, 2024
1 parent b7d0c72 commit 174dbd4
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 123 deletions.
114 changes: 23 additions & 91 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ chrono = { version = "0.4", features = ["serde"] }
clap = { version = "4", features = ["derive", "cargo", "env"] }
console = "0.15.0"
cpu-time = "1.0.0"
err-derive = "0.3"
futures = "0.3"
hdrhistogram = "7.1.0"
hytra = "0.1.2"
Expand Down
48 changes: 27 additions & 21 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,53 +1,59 @@
use crate::scripting::cass_error::CassError;
use err_derive::*;
use hdrhistogram::serialization::interval_log::IntervalLogWriterError;
use hdrhistogram::serialization::V2DeflateSerializeError;
use rune::alloc;
use std::path::PathBuf;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum LatteError {
#[error(display = "Context data could not be serialized: {}", _0)]
ContextDataEncode(#[source] rmp_serde::encode::Error),
#[error("Context data could not be serialized: {0}")]
ContextDataEncode(#[from] rmp_serde::encode::Error),

#[error(display = "Context data could not be deserialized: {}", _0)]
ContextDataDecode(#[source] rmp_serde::decode::Error),
#[error("Context data could not be deserialized: {0}")]
ContextDataDecode(#[from] rmp_serde::decode::Error),

#[error(display = "Cassandra error: {}", _0)]
#[error("Cassandra error: {0}")]
Cassandra(#[source] CassError),

#[error(display = "Failed to read file {:?}: {}", _0, _1)]
#[error("Failed to read file {0:?}: {1}")]
ScriptRead(PathBuf, #[source] rune::source::FromPathError),

#[error(display = "Failed to load script: {}", _0)]
ScriptBuildError(#[source] rune::BuildError),
#[error("Failed to load script: {0}")]
ScriptBuildError(#[from] rune::BuildError),

#[error(display = "Failed to execute script function {}: {}", _0, _1)]
#[error("Failed to execute script function {0}: {1}")]
ScriptExecError(String, rune::runtime::VmError),

#[error(display = "Function {} returned error: {}", _0, _1)]
#[error("Function {0} returned error: {1}")]
FunctionResult(String, String),

#[error(display = "{}", _0)]
Diagnostics(#[source] rune::diagnostics::EmitError),
#[error("{0}")]
Diagnostics(#[from] rune::diagnostics::EmitError),

#[error(display = "Failed to create output file {:?}: {}", _0, _1)]
#[error("Failed to create output file {0:?}: {1}")]
OutputFileCreate(PathBuf, std::io::Error),

#[error(display = "Failed to create log file {:?}: {}", _0, _1)]
#[error("Failed to create log file {0:?}: {1}")]
LogFileCreate(PathBuf, std::io::Error),

#[error(display = "Error writing HDR log: {}", _0)]
HdrLogWrite(#[source] IntervalLogWriterError<V2DeflateSerializeError>),
#[error("Error writing HDR log: {0}")]
HdrLogWrite(#[from] IntervalLogWriterError<V2DeflateSerializeError>),

#[error(display = "Failed to launch external editor {}: {}", _0, _1)]
#[error("Failed to launch external editor {0}: {1}")]
ExternalEditorLaunch(String, std::io::Error),

#[error(display = "Invalid configuration: {}", _0)]
#[error("Invalid configuration: {0}")]
Configuration(String),

#[error(display = "Memory allocation failure: {}", _0)]
OutOfMemory(#[source] alloc::Error),
#[error("Memory allocation failure: {0}")]
OutOfMemory(#[from] alloc::Error),
}

impl From<CassError> for LatteError {
fn from(err: CassError) -> Self {
LatteError::Cassandra(err)
}
}

impl LatteError {}
Expand Down
Loading

0 comments on commit 174dbd4

Please sign in to comment.