Skip to content

Commit dbeb33a

Browse files
committed
Use anyhow for pretty-printing errors
1 parent 25d0a05 commit dbeb33a

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ opentelemetry-semantic-conventions = "0.29.0"
3232
pest = "2.8.0"
3333
pest_derive = "2.8.0"
3434
tabled = "0.18.0"
35+
anyhow = "1.0.97"

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct Args {
4040
}
4141

4242
#[tokio::main]
43-
async fn main() -> Result<(), Box<dyn std::error::Error>> {
43+
async fn main() -> anyhow::Result<()> {
4444
let args = Args::parse();
4545
let mut logger_provider = None;
4646

@@ -72,7 +72,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
7272
Ok(())
7373
}
7474

75-
fn print_code(args: &Args) -> Result<(), Box<dyn std::error::Error>> {
75+
fn print_code(args: &Args) -> anyhow::Result<()> {
7676
let file_path = args.file_path.clone();
7777
let file_content = fs::read_to_string(&file_path)?;
7878
let ast = parser::parse(&file_content)?;
@@ -85,7 +85,7 @@ fn print_code(args: &Args) -> Result<(), Box<dyn std::error::Error>> {
8585
Ok(())
8686
}
8787

88-
async fn execute_code(args: &Args) -> Result<(), Box<dyn std::error::Error>> {
88+
async fn execute_code(args: &Args) -> anyhow::Result<()> {
8989
let file_path = args.file_path.clone();
9090
let file_content = fs::read_to_string(&file_path)?;
9191
let ast = parser::parse(&file_content)?;

src/otel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use tracing_subscriber::prelude::*;
1010
pub fn setup_otlp(
1111
endpoint: &str,
1212
service_name: &str,
13-
) -> Result<SdkLoggerProvider, Box<dyn std::error::Error>> {
13+
) -> Result<SdkLoggerProvider, opentelemetry_otlp::ExporterBuildError> {
1414
let mut metadata = MetadataMap::new();
1515
metadata.insert(SERVICE_NAME, service_name.parse().unwrap());
1616
let exporter = LogExporter::builder()

0 commit comments

Comments
 (0)