Skip to content

Commit 57dbbf8

Browse files
huseyinacacak-janeaaduh95
authored andcommitted
src: fix winapi_strerror error string
Fixes: #23191 PR-URL: #55207 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 008fb5f commit 57dbbf8

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

src/api/exceptions.cc

+8-8
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ Local<Value> UVException(Isolate* isolate,
157157
static const char* winapi_strerror(const int errorno, bool* must_free) {
158158
char* errmsg = nullptr;
159159

160-
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
161-
FORMAT_MESSAGE_IGNORE_INSERTS,
162-
nullptr,
163-
errorno,
164-
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
165-
reinterpret_cast<LPTSTR>(&errmsg),
166-
0,
167-
nullptr);
160+
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
161+
FORMAT_MESSAGE_IGNORE_INSERTS,
162+
nullptr,
163+
errorno,
164+
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
165+
reinterpret_cast<LPSTR>(&errmsg),
166+
0,
167+
nullptr);
168168

169169
if (errmsg) {
170170
*must_free = true;

test/parallel/test-debug-process.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const child = require('child_process');
5+
6+
if (!common.isWindows) {
7+
common.skip('This test is specific to Windows to test winapi_strerror');
8+
}
9+
10+
// Ref: https://github.com/nodejs/node/issues/23191
11+
// This test is specific to Windows.
12+
13+
const cp = child.spawn('pwd');
14+
15+
cp.on('exit', common.mustCall(function() {
16+
try {
17+
process._debugProcess(cp.pid);
18+
} catch (error) {
19+
assert.strictEqual(error.message, 'The system cannot find the file specified.');
20+
}
21+
}));

0 commit comments

Comments
 (0)