You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's generally good practice to add specific error handling and logging, especially for file paths and external tools like tonic_build, and also Use Constants for instance;
If "src/proto/blocks.proto" is a fixed path that might be reused elsewhere, consider defining it as a constant for maintainability.
below is an improved version that includes these suggestions
fn main() -> Result<(), Box> {
// Check if the .proto file exists before attempting to compile
if !Path::new(PROTO_PATH).exists() {
eprintln!("Error: The .proto file at '{}' was not found.", PROTO_PATH);
return Err("Proto file not found".into());
}
// Compile the proto files and handle errors
tonic_build::compile_protos(PROTO_PATH)
.map_err(|e| {
eprintln!("Error compiling proto files: {}", e);
e
})?;
println!("Proto files compiled successfully.");
Ok(())
}
this is a potential suggestion. Thanks
The text was updated successfully, but these errors were encountered:
Boss-DG
changed the title
possible improvement on the snapchain v0 src code
possible improvement on the snapchain v0 code. file path : github.com/farcasterxyz/snapchain-v0/blob/main/build.rs
Oct 26, 2024
It's generally good practice to add specific error handling and logging, especially for file paths and external tools like tonic_build, and also Use Constants for instance;
If "src/proto/blocks.proto" is a fixed path that might be reused elsewhere, consider defining it as a constant for maintainability.
below is an improved version that includes these suggestions
use std::error::Error;
use std::path::Path;
const PROTO_PATH: &str = "src/proto/blocks.proto";
fn main() -> Result<(), Box> {
// Check if the .proto file exists before attempting to compile
if !Path::new(PROTO_PATH).exists() {
eprintln!("Error: The .proto file at '{}' was not found.", PROTO_PATH);
return Err("Proto file not found".into());
}
}
this is a potential suggestion. Thanks
The text was updated successfully, but these errors were encountered: