From 28c779c843316e180c411302863da7dc8606f8e9 Mon Sep 17 00:00:00 2001 From: Milo Turner Date: Sat, 7 Mar 2020 20:47:43 -0500 Subject: [PATCH] backtrace --- hptp-recv/src/main.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hptp-recv/src/main.rs b/hptp-recv/src/main.rs index a0b8feb..8bed5ce 100644 --- a/hptp-recv/src/main.rs +++ b/hptp-recv/src/main.rs @@ -1,3 +1,4 @@ +#![feature(backtrace)] extern crate hptp; extern crate tokio; #[macro_use] @@ -9,8 +10,12 @@ use tokio::net::UdpSocket; #[derive(Error, Debug)] enum Error { - #[error("io error: {0}")] - Io(#[from] tokio::io::Error), + #[error("io error: {source}")] + Io { + #[from] + source: tokio::io::Error, + backtrace: std::backtrace::Backtrace, + }, #[error("no UDP port available for listening")] NoPortAvail, } @@ -23,7 +28,11 @@ fn entry() -> Result<(), Error> { fn main() { if let Err(e) = entry() { - println!("ERROR: {}", e); + use std::error::Error; + println!("Error: {}", e); + for bt in e.backtrace() { + println!("{}", bt); + } } }