Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
replace ERR_UNK_STATE with ERR_UNKNOWN_DEBUGGER_STATE
Add more explanation for the error code and replace it with a more verbose alternative
  • Loading branch information
shubheksha committed Feb 14, 2017
commit 86adefae9c835dc47be4df5f78b965c662c75f8b
6 changes: 3 additions & 3 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ found [here][online].
<a id="nodejs-error-codes"></a>
## Node.js Error Codes

<a id="ERR_UNK_STATE"></a>
### ERR_INVALID_CALLBACK
<a id="ERR_UNKNOWN_DEBUGGER_STATE"></a>
### ERR_UNKNOWN_DEBUGGER_STATE

The `'ERR_UNK_STATE'` error code is used to identify that the current state is not known.
The `'ERR_UNKNOWN_DEBUGGER_STATE'` error code is used to identify that the state of the debugger is not known.
Copy link
Copy Markdown
Member

@joyeecheung joyeecheung Feb 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shubheksha According to the history I think the test of this comes from #8454 and the code dates back to 8d82ec2, this looks like just a safety net in case anyone accidentally set the .state from outside and break the state machine, so probably we can add a sentence at the end: ...not known, possibly set by code outside the debugger module.

On another note, debugger module is deprecated and is going to be replaced by node inspect, so this error probably would not stay that long in the code base. Thanks for the contribution anyway!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can you add a line break in the sentence so it wraps in ~80 characters? Thanks!

2 changes: 1 addition & 1 deletion lib/_debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Protocol.prototype.execute = function(d) {
break;

default:
throw new errors.Error('ERR_UNK_STATE');
throw new errors.Error('ERR_UNKNOWN_DEBUGGER_STATE');
}
};

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ module.exports = exports = {
// Note: Please try to keep these in alphabetical order
E('ERR_ASSERTION', (msg) => msg);
// Add new errors from here...
E('ERR_UNK_STATE', 'Unknown state');
E('ERR_UNKNOWN_DEBUGGER_STATE', 'Unknown state');
2 changes: 1 addition & 1 deletion test/parallel/test-debug-protocol-execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ assert.strictEqual(protocol.res.body, undefined);
protocol.state = 'sterrance';
assert.throws(
() => { protocol.execute('grumblecakes'); },
common.expectsError('ERR_UNK_STATE', Error)
common.expectsError('ERR_UNKNOWN_DEBUGGER_STATE', Error)
);