-
Notifications
You must be signed in to change notification settings - Fork 178
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
Show an error message when an error response does not have JSON #157
Show an error message when an error response does not have JSON #157
Conversation
function handleMessage(req, sender, sendResponse) { | ||
if (req.type === 'request') { | ||
var url = tabInfo[req.tabId].remoteHost + '/' + req.url; | ||
REPLConsole.request(req.method, url, req.params, function(xhr) { | ||
sendResponse({ status: xhr.status, responseText: xhr.responseText }); | ||
sendResponse(extractProps(xhr)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is to use xhr.statusText
.
Didn't we issue the message before? Also most of the messages we currently have are pretty prosaic. I think its okay to drop the |
f490f58
to
2871284
Compare
OK, updated:
And here is a diff of the message: - ERROR: connection is refused
+ Oops! Failed to connect to Web Console middleware.
+ Please make sure that web server is running. Thanks! |
Can we move this to its own PR? |
2871284
to
87ab763
Compare
OK, I have moved it. |
|
||
function getErrorText(xhr) { | ||
if (!xhr.status) { | ||
return "Oops! Failed to connect to Web Console middleware.\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be a good idea to collect all the messages we have and put them in config/locale/en.yml or something like this. It will open the door for internationalization and will get rid of those hard-coded messages from the code-base. Just some food for thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, let's do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be my native language parasite skills kicking in, but maybe we can reword the following sections:
- connect to Web Console
+ connect to the Web Console
... and:
- Please make sure that web server is running.
+ Please make sure a rails development server is running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a valuable point to me :-)
Let's make a final message pass and this PR is good to go. 👍 |
87ab763
to
4575a2b
Compare
@@ -0,0 +1,2 @@ | |||
require 'active_support/core_ext/string/access' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for doing this!
You can actually put it inside an initializer in the Railtie.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can actually put it inside an initializer in the Railtie.
OK, I will change it.
4575a2b
to
0f47ed9
Compare
Updated again ♻️
Thanks. |
@@ -66,5 +66,9 @@ class Railtie < ::Rails::Railtie | |||
Middleware.whiny_requests = config.web_console.whiny_requests | |||
end | |||
end | |||
|
|||
initializer 'i18n.load_path' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly that, yes! 👍
Thanks a lot! |
Show an error message when an error response does not have JSON
After stopping a web server, the console is not doing anything even if a user types commands. It might cause a little confusion to the users.
This pull request is to show an error message in such that case, and also show a HTTP status code when an error response does not have a JSON-formatted text (see the test case: fb979f8).
Example
GIF: start server => stop server => restart server
Thanks.