From b3806e66ade22630e9dda07b873cf857c5bd0149 Mon Sep 17 00:00:00 2001 From: Matthew Pomes Date: Fri, 22 Nov 2024 14:10:42 -0600 Subject: [PATCH] Fix more small things --- core/lib/src/data/data.rs | 2 +- core/lib/src/data/from_data.rs | 6 ++++-- core/lib/src/request/from_param.rs | 8 ++++---- core/lib/src/request/from_request.rs | 5 +++-- docs/guide/12-pastebin.md | 4 ++-- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/core/lib/src/data/data.rs b/core/lib/src/data/data.rs index d5ea8d9e1d..82db59fb92 100644 --- a/core/lib/src/data/data.rs +++ b/core/lib/src/data/data.rs @@ -114,7 +114,7 @@ impl<'r> Data<'r> { /// use rocket::data::{Data, FromData, Outcome}; /// use rocket::http::Status; /// # struct MyType; - /// # #[derive(rocket::TypedError)] + /// # #[derive(rocket::TypedError, Debug)] /// # struct MyError; /// /// #[rocket::async_trait] diff --git a/core/lib/src/data/from_data.rs b/core/lib/src/data/from_data.rs index 758c6466dd..8abf2dc79d 100644 --- a/core/lib/src/data/from_data.rs +++ b/core/lib/src/data/from_data.rs @@ -1,3 +1,5 @@ +use std::fmt; + use crate::catcher::TypedError; use crate::http::RawStr; use crate::request::{Request, local_cache}; @@ -182,7 +184,7 @@ pub type Outcome<'r, T, E = >::Error> /// use rocket::request::Request; /// use rocket::data::{self, Data, FromData}; /// # struct MyType; -/// # #[derive(rocket::TypedError)] +/// # #[derive(rocket::TypedError, Debug)] /// # struct MyError; /// /// #[rocket::async_trait] @@ -312,7 +314,7 @@ pub type Outcome<'r, T, E = >::Error> #[crate::async_trait] pub trait FromData<'r>: Sized { /// The associated error to be returned when the guard fails. - type Error: TypedError<'r> + 'r; + type Error: TypedError<'r> + fmt::Debug + 'r; /// Asynchronously validates, parses, and converts an instance of `Self` /// from the incoming request body data. diff --git a/core/lib/src/request/from_param.rs b/core/lib/src/request/from_param.rs index 8257bf7ddc..aed9356c34 100644 --- a/core/lib/src/request/from_param.rs +++ b/core/lib/src/request/from_param.rs @@ -160,7 +160,7 @@ use crate::http::{uri::{Segments, error::PathError, fmt::Path}, Status}; /// use rocket::TypedError; /// # #[allow(dead_code)] /// # struct MyParam<'r> { key: &'r str, value: usize } -/// #[derive(TypedError)] +/// #[derive(TypedError, Debug)] /// struct MyParamError<'a>(&'a str); /// /// impl<'r> FromParam<'r> for MyParam<'r> { @@ -192,7 +192,7 @@ use crate::http::{uri::{Segments, error::PathError, fmt::Path}, Status}; /// # #[macro_use] extern crate rocket; /// # use rocket::request::FromParam; /// # use rocket::TypedError; -/// # #[derive(TypedError)] +/// # #[derive(TypedError, Debug)] /// # struct MyParamError<'a>(&'a str); /// # #[allow(dead_code)] /// # struct MyParam<'r> { key: &'r str, value: usize } @@ -215,7 +215,7 @@ use crate::http::{uri::{Segments, error::PathError, fmt::Path}, Status}; /// ``` pub trait FromParam<'a>: Sized { /// The associated error to be returned if parsing/validation fails. - type Error: TypedError<'a>; + type Error: TypedError<'a> + fmt::Debug + 'a; /// Parses and validates an instance of `Self` from a path parameter string /// or returns an `Error` if parsing or validation fails. @@ -397,7 +397,7 @@ impl<'a, T: FromParam<'a>> FromParam<'a> for Option { /// the `Utf8Error`. pub trait FromSegments<'r>: Sized { /// The associated error to be returned when parsing fails. - type Error: TypedError<'r>; + type Error: TypedError<'r> + fmt::Debug + 'r; /// Parses an instance of `Self` from many dynamic path parameter strings or /// returns an `Error` if one cannot be parsed. diff --git a/core/lib/src/request/from_request.rs b/core/lib/src/request/from_request.rs index 8d90e8b531..453ffe4ac2 100644 --- a/core/lib/src/request/from_request.rs +++ b/core/lib/src/request/from_request.rs @@ -1,4 +1,5 @@ use std::convert::Infallible; +use std::fmt; use std::net::{IpAddr, SocketAddr}; use crate::catcher::TypedError; @@ -36,7 +37,7 @@ pub type Outcome = outcome::Outcome; /// use rocket::request::{self, Request, FromRequest}; /// # struct MyType; /// # use rocket::TypedError; -/// # #[derive(TypedError)] +/// # #[derive(TypedError, Debug)] /// # struct MyError; /// /// #[rocket::async_trait] @@ -408,7 +409,7 @@ pub type Outcome = outcome::Outcome; #[crate::async_trait] pub trait FromRequest<'r>: Sized { /// The associated error to be returned if derivation fails. - type Error: TypedError<'r> + 'r; + type Error: TypedError<'r> + fmt::Debug + 'r; /// Derives an instance of `Self` from the incoming request metadata. /// diff --git a/docs/guide/12-pastebin.md b/docs/guide/12-pastebin.md index 36182be5f8..56147a345d 100644 --- a/docs/guide/12-pastebin.md +++ b/docs/guide/12-pastebin.md @@ -367,7 +367,7 @@ use rocket::tokio::fs::File; # pub fn new(size: usize) -> PasteId<'static> { todo!() } # pub fn file_path(&self) -> PathBuf { todo!() } # } -# #[derive(rocket::TypedError)] +# #[derive(Debug, rocket::TypedError)] # pub struct InvalidPasteId; # impl<'a> FromParam<'a> for PasteId<'a> { # type Error = InvalidPasteId; @@ -446,7 +446,7 @@ pub struct PasteId<'a>(Cow<'a, str>); # pub fn file_path(&self) -> PathBuf { todo!() } # } # -# #[derive(rocket::TypedError)] +# #[derive(Debug, rocket::TypedError)] # pub struct InvalidPasteId; # impl<'a> FromParam<'a> for PasteId<'a> { # type Error = InvalidPasteId;