Skip to content

debugger, errors: migrate to use internal/errors.js #11380

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,19 @@ 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_UNKNOWN_DEBUGGER_STATE"></a>
### ERR_UNKNOWN_DEBUGGER_STATE

The `'ERR_UNKNOWN_DEBUGGER_STATE'` error code is used to identify that the state
of the debugger is not known, possibly set by code outside the debugger module.
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_UNKNOWN_DEBUGGER_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_UNKNOWN_DEBUGGER_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_UNKNOWN_DEBUGGER_STATE', Error)
);