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

errors,http_server: migrate to use internal/errors.js #13301

Closed
wants to merge 1 commit into from

Conversation

@bidipyne
Copy link
Contributor

@bidipyne bidipyne commented May 30, 2017

Checklist

  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

_http_server.js
internal/errors.js

ref: #11273
I read and understood the contribution guidelines, please review and suggest.
@jasnell
Thanks.

lib/_http_server.js Outdated
@@ -211,8 +212,8 @@ function writeHead(statusCode, reason, obj) {
}
if (k === undefined) {
if (this._header) {
throw new Error('Can\'t render headers after they are sent to the ' +
'client');
throw new errors.Error('ERR_ASSERTION', 'Can\'t render headers ' +

This comment has been minimized.

@jasnell

jasnell May 30, 2017
Member

Since we're updating anyway, it would be nice to get rid of the contraction.

Cannot render headers ...

This comment has been minimized.

@jasnell

jasnell May 30, 2017
Member

ERR_ASSERTION is the wrong choice here. That should be reserved for uses of the assert module. A new error code would be more appropriate.

This comment has been minimized.

@bidipyne

bidipyne May 31, 2017
Author Contributor

@jasnell Rectifications done. Thank You

lib/_http_server.js Outdated
@@ -223,7 +224,8 @@ function writeHead(statusCode, reason, obj) {
}

if (common._checkInvalidHeaderChar(this.statusMessage))
throw new Error('Invalid character in statusMessage.');
throw new errors.Error('ERR_ASSERTION', 'Invalid character in ' +
'statusMessage.');

This comment has been minimized.

@jasnell

jasnell May 30, 2017
Member

Likewise, ERR_ASSERTION is the wrong choice here. A new error code would be better.

This comment has been minimized.

@bidipyne

bidipyne May 31, 2017
Author Contributor

Done!

lib/internal/errors.js Outdated
@@ -117,13 +117,16 @@ E('ERR_CONSOLE_WRITABLE_STREAM',
E('ERR_INDEX_OUT_OF_RANGE', 'Index out of range');
E('ERR_INVALID_ARG_TYPE', invalidArgType);
E('ERR_INVALID_CALLBACK', 'callback must be a function');
E('ERR_INVALID_CHAR', 'Invalid character in statusMessage.');

This comment has been minimized.

@jasnell

jasnell May 31, 2017
Member

Since this is specific to http, perhaps ERR_HTTP_INVALID_CHAR

This comment has been minimized.

@bidipyne

bidipyne May 31, 2017
Author Contributor

Re-phrased.

lib/internal/errors.js Outdated
E('ERR_INVALID_FILE_URL_HOST', 'File URL host %s');
E('ERR_INVALID_FILE_URL_PATH', 'File URL path %s');
E('ERR_INVALID_HANDLE_TYPE', 'This handle type cannot be sent');
E('ERR_INVALID_OPT_VALUE',
(name, value) => {
return `The value "${String(value)}" is invalid for option "${name}"`;
});
E('ERR_INVALID_STATUS_CODE',
(originalStatusCode) => `Invalid status code: ${originalStatusCode}`);

This comment has been minimized.

@jasnell

jasnell May 31, 2017
Member

same here... ERR_HTTP_INVALID_STATUS_CODE

This comment has been minimized.

@bidipyne

bidipyne May 31, 2017
Author Contributor

Done!

lib/internal/errors.js Outdated
@@ -139,6 +142,8 @@ E('ERR_IPC_DISCONNECTED', 'IPC channel is already disconnected');
E('ERR_IPC_ONE_PIPE', 'Child process can have only one IPC pipe');
E('ERR_IPC_SYNC_FORK', 'IPC cannot be used with synchronous forks');
E('ERR_MISSING_ARGS', missingArgs);
E('ERR_RENDER_HEADER',
'Cannot render headers after they are sent to the client');

This comment has been minimized.

@jasnell

jasnell May 31, 2017
Member

ERR_HTTP_HEADERS_SENT ?

This comment has been minimized.

@bidipyne

bidipyne May 31, 2017
Author Contributor

Rectified. Thanks!

test/parallel/test-http-response-statuscode.js Outdated
@@ -1,3 +1,5 @@
// Flags: --expose-internals

This comment has been minimized.

@jasnell

jasnell May 31, 2017
Member

This shouldn't need the --expose-internals flag

This comment has been minimized.

@bidipyne

bidipyne May 31, 2017
Author Contributor

Removed.

test/parallel/test-http-write-head.js Outdated
@@ -19,6 +19,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

// Flag: --expose-internals

This comment has been minimized.

@jasnell

jasnell May 31, 2017
Member

Likewise, this shouldn't need the --expose-internals flag

This comment has been minimized.

@bidipyne

bidipyne May 31, 2017
Author Contributor

Removed.

Copy link
Member

@mhdawson mhdawson left a comment

LGTM with a nit

lib/_http_server.js Outdated
@@ -223,7 +225,8 @@ function writeHead(statusCode, reason, obj) {
}

if (common._checkInvalidHeaderChar(this.statusMessage))
throw new Error('Invalid character in statusMessage.');
throw new errors.Error('ERR_HTTP_INVALID_CHAR', 'Invalid character in ' +

This comment has been minimized.

@mhdawson

mhdawson May 31, 2017
Member

I'm guessing its broken into 2 strings to avoid the long line. I'm not sure I've seen us use the + for this, instead could you just put the 'Invalid ...' on a second line

This comment has been minimized.

@bidipyne

bidipyne Jun 1, 2017
Author Contributor

Done as per suggestion. Thanks!

@jasnell
jasnell approved these changes Jun 1, 2017
jasnell added a commit that referenced this pull request Jun 2, 2017
PR-URL: #13301
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell
Copy link
Member

@jasnell jasnell commented Jun 2, 2017

Landed in a9f798e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Error Codes
  
Done
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.