backtrace

This commit is contained in:
Milo Turner 2020-03-07 20:47:43 -05:00
parent fa477593fa
commit 28c779c843
1 changed files with 12 additions and 3 deletions

View File

@ -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);
}
}
}