Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace #[error] behind #[rocket(error)] #231

Closed
mehcode opened this issue Mar 17, 2017 · 4 comments
Closed

Namespace #[error] behind #[rocket(error)] #231

mehcode opened this issue Mar 17, 2017 · 4 comments
Labels
declined A declined request or suggestion request Request for new functionality

Comments

@mehcode
Copy link
Contributor

mehcode commented Mar 17, 2017

Both log and slog use error! for error logging. This conflicts with #[error] as both attribute macros and functional macros share the same scope.

I propose that we make it policy to namespace attribute macros outside of the standard HTTP methods and route.

#[rocket(error(404))]
fn not_found(req: &Request) -> String { }
@SergioBenitez SergioBenitez added the request Request for new functionality label Mar 17, 2017
@SergioBenitez
Copy link
Member

Macro namespace conflicts will be resolved with macros 2.0, part of #19. As a result, namespacing macros in this way will be unnecessary. Furthermore, the aesthetics of what you've proposed are subpar. For these reasons, I am declining this request and closing the issue.

That being said, I have considered renaming error to catcher or catch to better declare its intention. This would inadvertently solve the problem.

@SergioBenitez SergioBenitez added the declined A declined request or suggestion label Mar 17, 2017
@mehcode
Copy link
Contributor Author

mehcode commented Mar 17, 2017

@SergioBenitez I agree with switching to using #[catch]. Rust is adding catch as a contextual keyword so it seems to be the de-facto word for this kind of thing.

I was under the impression that macros (both attribute and functional) would move to using normal use instead of "magic" scope. This is still a conflict (though not as serious) as I'd imagine you'd start having use rocket::prelude::* recommended same as slog would recommend use slog::prelude::*.

@SergioBenitez
Copy link
Member

@Nemikolh
Copy link

Hi, is there a workaround or a way to declare an error handler outside of using the error macro?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
declined A declined request or suggestion request Request for new functionality
Projects
None yet
Development

No branches or pull requests

3 participants