Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit572a938

Browse files
committed
adjust error mesages to provide more useful output
1 parent752a2a8 commit572a938

File tree

2 files changed

+55
-4
lines changed

2 files changed

+55
-4
lines changed

‎src/sshConfig.test.ts

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,59 @@ Host afterconfig
300300
LogLevel:"ERROR",
301301
}),
302302
).rejects.toThrow(
303-
`Malformed config:ssh config has 2 dev.coder.comSTARTcomments but 1dev.coder.comEND comments.Each START must havea matchingEND.`,
303+
`Malformed config:UnterminatedSTARTCODER VSCODEdev.coder.comblock:Each STARTblockmust haveanEND block.`,
304304
)
305305
})
306306

307+
it("throws an error if there is a mismatched start and end block count (without label)",async()=>{
308+
// As above, but without a label.
309+
constexistentSSHConfig=`Host beforeconfig
310+
HostName before.config.tld
311+
User before
312+
313+
# --- START CODER VSCODE ---
314+
Host coder-vscode.dev.coder.com--*
315+
ConnectTimeout 0
316+
LogLevel ERROR
317+
ProxyCommand some-command-here
318+
StrictHostKeyChecking no
319+
UserKnownHostsFile /dev/null
320+
# missing END CODER VSCODE ---
321+
322+
Host donotdelete
323+
HostName dont.delete.me
324+
User please
325+
326+
# --- START CODER VSCODE ---
327+
Host coder-vscode.dev.coder.com--*
328+
ConnectTimeout 0
329+
LogLevel ERROR
330+
ProxyCommand some-command-here
331+
StrictHostKeyChecking no
332+
UserKnownHostsFile /dev/null
333+
# --- END CODER VSCODE ---
334+
335+
Host afterconfig
336+
HostName after.config.tld
337+
User after`
338+
339+
constsshConfig=newSSHConfig(sshFilePath,mockFileSystem)
340+
mockFileSystem.readFile.mockResolvedValueOnce(existentSSHConfig)
341+
awaitsshConfig.load()
342+
343+
// When we try to update the config, it should throw an error.
344+
awaitexpect(
345+
sshConfig.update("",{
346+
Host:"coder-vscode.dev.coder.com--*",
347+
ProxyCommand:"some-command-here",
348+
ConnectTimeout:"0",
349+
StrictHostKeyChecking:"no",
350+
UserKnownHostsFile:"/dev/null",
351+
LogLevel:"ERROR",
352+
}),
353+
).rejects.toThrow(`Malformed config: Unterminated START CODER VSCODE block: Each START block must have an END block.`)
354+
})
355+
307356
it("throws an error if there are more than one sections with the same label",async()=>{
308357
constexistentSSHConfig=`Host beforeconfig
309358
HostName before.config.tld
@@ -349,7 +398,9 @@ Host afterconfig
349398
UserKnownHostsFile:"/dev/null",
350399
LogLevel:"ERROR",
351400
}),
352-
).rejects.toThrow(`Malformed config: ssh config has 2 dev.coder.com sections, please remove all but one.`)
401+
).rejects.toThrow(
402+
`Malformed config: ssh config has 2 START CODER VSCODE dev.coder.com sections, please remove all but one.`,
403+
)
353404
})
354405

355406
it("correctly handles interspersed blocks with and without label",async()=>{

‎src/sshConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ export class SSHConfig {
138138

139139
if(startBlockCount!==endBlockCount){
140140
thrownewSSHConfigBadFormat(
141-
`Malformed config:ssh config has${startBlockCount}${label} START comments but${endBlockCount}${label} END comments. Each START must havea matchingEND.`,
141+
`Malformed config:Unterminated START CODER VSCODE${label ?label+" " :""}block: Each STARTblockmust haveanEND block.`,
142142
)
143143
}
144144
if(startBlockCount>1||endBlockCount>1){
145145
thrownewSSHConfigBadFormat(
146-
`Malformed config: ssh config has${startBlockCount}${label}sections, please remove all but one.`,
146+
`Malformed config: ssh config has${startBlockCount}START CODER VSCODE${label ?label+" " :""}sections, please remove all but one.`,
147147
)
148148
}
149149

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp