-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Description
The Sentry project has an example code that demonstrates how to use it in main()
.
Presence of main()
in that example is not an accident. It demonstrates how typically a server app is structured, and this helps the reader to understand where to put the code.
Although technically fn main()
could be removed from this code, it'd make definition of fn failing
look weird.
I suggest not warning about needless_doctest_main
if there is a definition of another non-main
function.
//! ```
//! use std::env;
//! use std::io;
//!
//! use actix_web::{server, App, Error, HttpRequest};
//! use sentry_actix::SentryMiddleware;
//!
//! fn failing(_req: &HttpRequest) -> Result<String, Error> {
//! Err(io::Error::new(io::ErrorKind::Other, "An error happens here").into())
//! }
//!
//! fn main() {
//! let _guard = sentry::init("https://[email protected]/1234");
//! env::set_var("RUST_BACKTRACE", "1");
//! sentry::integrations::panic::register_panic_handler();
//!
//! server::new(|| {
//! App::new()
//! .middleware(SentryMiddleware::new())
//! .resource("/", |r| r.f(failing))
//! }).bind("127.0.0.1:3001")
//! .unwrap()
//! .run();
//! }
//! ```
JohnTitor and jonhoo
Metadata
Metadata
Assignees
Labels
No labels