Skip to content

Commit 405e051

Browse files
author
Brian Jenkins
authored
Fix EBADPLATFORM error message (#1876)
* Fix EBADPLATFORM error message Error format evolved out from under message generation's expectations. * Fix formatting
1 parent 9bc6966 commit 405e051

3 files changed

Lines changed: 26 additions & 8 deletions

File tree

lib/utils/error-message.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,12 @@ module.exports = (er) => {
220220
break
221221

222222
case 'EBADPLATFORM': {
223-
const validOs = er.os.join ? er.os.join(',') : er.os
224-
const validArch = er.cpu.join ? er.cpu.join(',') : er.cpu
223+
const validOs = er.required &&
224+
er.required.os &&
225+
er.required.os.join ? er.required.os.join(',') : er.required.os
226+
const validArch = er.required &&
227+
er.required.cpu &&
228+
er.required.cpu.join ? er.required.cpu.join(',') : er.required.cpu
225229
const expected = { os: validOs, arch: validArch }
226230
const actual = { os: process.platform, arch: process.arch }
227231
short.push([

tap-snapshots/test-lib-utils-error-message.js-TAP.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Object {
161161
"summary": Array [
162162
Array [
163163
"notsup",
164-
"Unsupported platform for undefined: wanted {\\"os\\":\\"!yours,mine\\",\\"arch\\":\\"x420,x69\\"} (current: {\\"os\\":\\"posix\\",\\"arch\\":\\"x64\\"})",
164+
"Unsupported platform for [email protected]: wanted {\\"os\\":\\"!yours,mine\\",\\"arch\\":\\"x420,x69\\"} (current: {\\"os\\":\\"posix\\",\\"arch\\":\\"x64\\"})",
165165
],
166166
],
167167
}
@@ -178,7 +178,7 @@ Object {
178178
"summary": Array [
179179
Array [
180180
"notsup",
181-
"Unsupported platform for undefined: wanted {\\"os\\":\\"!yours\\",\\"arch\\":\\"x420\\"} (current: {\\"os\\":\\"posix\\",\\"arch\\":\\"x64\\"})",
181+
"Unsupported platform for [email protected]: wanted {\\"os\\":\\"!yours\\",\\"arch\\":\\"x420\\"} (current: {\\"os\\":\\"posix\\",\\"arch\\":\\"x64\\"})",
182182
],
183183
],
184184
}

test/lib/utils/error-message.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,17 +406,31 @@ t.test('404', t => {
406406
t.test('bad platform', t => {
407407
t.test('string os/arch', t => {
408408
const er = Object.assign(new Error('a bad plat'), {
409-
os: '!yours',
410-
cpu: 'x420',
409+
410+
current: {
411+
os: 'posix',
412+
cpu: 'x64'
413+
},
414+
required: {
415+
os: '!yours',
416+
cpu: 'x420'
417+
},
411418
code: 'EBADPLATFORM'
412419
})
413420
t.matchSnapshot(errorMessage(er))
414421
t.end()
415422
})
416423
t.test('array os/arch', t => {
417424
const er = Object.assign(new Error('a bad plat'), {
418-
os: ['!yours', 'mine'],
419-
cpu: ['x420', 'x69'],
425+
426+
current: {
427+
os: 'posix',
428+
cpu: 'x64'
429+
},
430+
required: {
431+
os: ['!yours', 'mine'],
432+
cpu: ['x420', 'x69']
433+
},
420434
code: 'EBADPLATFORM'
421435
})
422436
t.matchSnapshot(errorMessage(er))

0 commit comments

Comments
 (0)