Skip to content

Commit

Permalink
fixup! second commit: first custom error type
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Zhirkov authored and Igor Zhirkov committed Nov 25, 2024
1 parent 188f3b5 commit 8a97b94
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ use crate::namespaces::{
};

use zksync_error::error::definitions::TestNode;
use zksync_error::packed::pack;
use zksync_error::serialized::serialize;
use zksync_error::serialized::SerializedError;

#[allow(clippy::too_many_arguments)]
Expand Down Expand Up @@ -113,14 +111,13 @@ async fn build_json_http<

#[tokio::main]
async fn main() -> Result<(), SerializedError> {
fn generic_error<T: std::fmt::Display>(e: T) -> SerializedError {
serialize(pack(TestNode::TestNodeError {
fn generic_error<T: std::fmt::Display>(e: T) -> TestNode {
TestNode::TestNodeError {
inner: e.to_string(),
}))
.unwrap()
}.into()
}
fn generic_error_msg(msg: impl Into<String>) -> SerializedError {
serialize(pack(TestNode::TestNodeError { inner: msg.into() })).unwrap()
fn generic_error_msg(msg: impl Into<String>) -> TestNode {
TestNode::TestNodeError { inner: msg.into() }.into()
}

// Check for deprecated options
Expand All @@ -133,11 +130,10 @@ async fn main() -> Result<(), SerializedError> {

let log_level_filter = LevelFilter::from(config.log_level);
let log_file = File::create(&config.log_file_path).map_err(|e| {
serialize(pack(TestNode::LogFileCreationError {
TestNode::LogFileCreationError {
path: config.log_file_path.to_string(),
inner: e.to_string(),
}))
.unwrap()
}
})?;

// Initialize the tracing subscriber
Expand Down

0 comments on commit 8a97b94

Please sign in to comment.