Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
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
9 changes: 9 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,18 @@ found [here][online].
[domains]: domain.html
[event emitter-based]: events.html#events_class_eventemitter
[file descriptors]: https://en.wikipedia.org/wiki/File_descriptor
[Node.js Error Codes]: #nodejs-error-codes
[online]: http://man7.org/linux/man-pages/man3/errno.3.html
[stream-based]: stream.html
[syscall]: http://man7.org/linux/man-pages/man2/syscall.2.html
[try-catch]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch
[V8's stack trace API]: https://github.com/v8/v8/wiki/Stack-Trace-API
[vm]: vm.html

<a id="nodejs-error-codes"></a>
## Node.js Error Codes

<a id="ERR_UNK_STATE"></a>
### ERR_INVALID_CALLBACK
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.

Code name doesn't match the anchor here. Also probably spelling the UNKNOWN in full would be easier to understand? The description below is not particularly helpful if someone encounters this error and tries to look it up, probably ERR_UNKNOWN_DEBUGGER_STATE and some more explanation would be better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry about that. I've fixed it in the latest commit. I'm not sure what more can I add to the explanation. Could you please guide me a little about that? Thanks!


The `'ERR_UNK_STATE'` error code is used to identify that the current state is not known.
3 changes: 2 additions & 1 deletion lib/_debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const inherits = util.inherits;
const assert = require('assert');
const spawn = require('child_process').spawn;
const Buffer = require('buffer').Buffer;
const errors = require('internal/errors');

exports.start = function(argv, stdin, stdout) {
argv || (argv = process.argv.slice(2));
Expand Down Expand Up @@ -126,7 +127,7 @@ Protocol.prototype.execute = function(d) {
break;

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

Expand Down
1 change: 1 addition & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +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');
4 changes: 2 additions & 2 deletions test/parallel/test-debug-protocol-execute.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

require('../common');
const common = require('../common');
const assert = require('assert');
const debug = require('_debugger');

Expand All @@ -16,5 +16,5 @@ assert.strictEqual(protocol.res.body, undefined);
protocol.state = 'sterrance';
assert.throws(
() => { protocol.execute('grumblecakes'); },
/^Error: Unknown state$/
common.expectsError('ERR_UNK_STATE', Error)
);