How to default to blank page instead of Scorched error page ?

13 views
Skip to first unread message

scalp42

unread,
Mar 2, 2014, 4:22:03 PM3/2/14
to scor...@googlegroups.com
Hi Tom,

I tried setting:

config[:show_http_error_pages] = false

Yet I still get the default Scorched error page on a 405 method not allowed.

Any ideas please ?

I looked into the code but it appears the condition still get triggered in the after config: https://github.com/Wardrop/Scorched/blob/master/lib/scorched/controller.rb#L528

Thanks in advance!

Tom Wardrop

unread,
Mar 2, 2014, 6:45:44 PM3/2/14
to scor...@googlegroups.com
Hey Anthony,

I can't seem to reproduce this. Are you using the latest version of Scorched (v0.21)? Are you doing any funky code reloading? The only place where this setting is potentially overridden to `true` is here: https://github.com/Wardrop/Scorched/blob/master/lib/scorched/controller.rb#L40

I would suggest running a really simple app to see if you still have issues. Try running this example just using `rackup`: https://github.com/Wardrop/Scorched/blob/master/examples/simple.ru

Then try and access http://localhost:9292/blah/bleh. You should get the Scorched error page. If you then change the setting, `:show_http_error_pages` setting to false, you should just get a blank page; your browser's developer tools should reveal that it's still returning a 404 http status.

Cheers,
Tom




--
You received this message because you are subscribed to the Google Groups "Scorched" group.
To view this discussion on the web, visit https://groups.google.com/d/msgid/scorched/7c229bd5-161b-412a-a553-27146e2596af%40googlegroups.com.

scalp42

unread,
Mar 2, 2014, 7:14:26 PM3/2/14
to scor...@googlegroups.com
Thanks for the quick reply.

I noticed that it only works if you set it to false in the "main" controller.


I'm using latest version indeed 0.21

Thanks a lot again.

Tom Wardrop

unread,
Mar 2, 2014, 8:39:42 PM3/2/14
to scor...@googlegroups.com
Ok, good catch, I can see the problem now.

Scorched keeps track of what filters have been run to prevent inherited filters from running multiple times as the request traverses down and up the chain of controllers. The problem is that if a condition fails on a filter, it's not marked as `executed`. So what's happening in your example, is that when the `after` filters are run for `ApiV1`, the error page filter is skipped because it fails the configuration condition. However, because it's not marked as executed, as the request traverses up and back through the `Error` controller, the filter is being run there instead as all the conditions pass at that point.

I could just move this line up and outside the `unless` condition which would fix the issue: https://github.com/Wardrop/Scorched/blob/v0.21/lib/scorched/controller.rb#L564

However, there are other scenarios in which the current behaviour is preferred. In fact I have a spec that tests for this exact behaviour. So what I'll do instead is remove the conditions from this particular filter so it's always executed in the context of the end-point controller. This achieves the same result without affecting other scenarios.

I've just committed this and have released a v0.22 of Scorched which includes this change.

Tom




--
You received this message because you are subscribed to the Google Groups "Scorched" group.
Reply all
Reply to author
Forward
0 new messages