telers 1.0.0-beta.2

An asynchronous framework for Telegram Bot API written in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::{fmt::Write, iter};

pub fn format_error_report(err: &impl std::error::Error) -> String {
    let mut output = String::new();
    writeln!(&mut output, "{err}").unwrap();

    if let Some(cause) = err.source() {
        writeln!(&mut output, "\nCaused by:").unwrap();
        for (i, err) in iter::successors(Some(cause), |err| err.source()).enumerate() {
            writeln!(&mut output, "   {i}: {err}").unwrap();
        }
    }

    output
}