-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Split onNotFound in onDevNotFound and onProdNotFound #6116
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
Split onNotFound in onDevNotFound and onProdNotFound #6116
Conversation
|
Hum, mixed fellings about this since I use a different approach to handle dev and prod. What I do is have two Also, if we decide to have these methods, shouldn't this be available at |
|
The Your approach of having different implementations for the However I think it absolutely makes sense to split the methods into
I think this woud make it much more easier/straightforward for people to just override the not found page for production like they can do with server errors already. |
|
I think binding separate I think separate bindings would also be cleaner to test. You can explicitly override the binding to be a If we ignore the fact that |
Since I already have other settings that vary according to the environment, it does not add a burden. But I have a problem with APIs trying to handle more than one concept here (how to handle errors and dealing with the running mode). See more below.
That is exactly why I prefer this approach and consider it lighter. Testing it is way more easier since I don't have to worry about the running mode.
I think this is a place were a "private" API leaked. Most of the time, users should not worry about the running mode, but about what the application must do. It is Play responsibility to worry about how to different running modes affect the application (hot reloading or not, which default error page to show, etc). |
@marcospereira You may be right. See @richdougherty's comment on #3444:
So I agree that for the default error handling logic, we can do a check for mode. This way we know we are overriding Play's default logic no matter what context we're using the error handler in. But we never addressed what the right thing is for a user to do. On another note, the dependencies of class ProdHttpErrorHandler @Inject()(conf: Configuration, sm: OptionalSourceMapper, router: Provider[Router])
extends DefaultHttpErrorHandler(Mode.Prod, conf, sm, router) |
|
Also, |
|
Separate point: I don't like the naming. DevServerError and ProdServerError are not two different types of events. Method names that start with |
|
Actually, if we agree that separate dev/prod bindings is a better way to go, then I would just have one method (not sure about the naming) |
|
I am closing this in favor of #6171 |
The same is true for
onServerErroralready, which forwards toonDevServerErrorandonProdServerError.Right now when you override
onNotFoundyou always have to checkif (environment.isProd()) {...manually which is quite annoying, because in nearly all cases you probably don't want to override the not found page in dev mode, but keep Play's default one.Please backport to 2.5.x, thanks!