Skip to content

impl std::error::Error for StatusCode #672

@fakeshadow

Description

@fakeshadow

Sometimes I want to use status code as an error type like following:

fn method_guard(req: &Request<()>) -> Result<(), Box<dyn std::error::Error>> {
    if req.method() != Method::GET {
        return Err(Box::new(StatusCode::METHOD_NOT_ALLOWED));
    }
    Ok(())
}

Using a new type could resolve the issue but it's an inconvenience for library code where ideally I want to re-export http types as much as possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions