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

Commite5c2548

Browse files
fix(cli): handle nil unwrap errors when formatting (#18099)
Discovered an unhelpful error when running a CLI command without internet (I didn't know I didn't have internet!):```$ coder lsEncountered an error running "coder list", see "coder list --help" for more informationerror: <nil>```The source of this was that calling `Unwrap()` on `net.DNSError` can return nil, causing the whole error trace to get replaced by it. Instead, we'll just treat a nil `Unwrap()` return value as if there was nothing to unwrap.The result is:```$ coder lsEncountered an error running "coder list", see "coder list --help" for more informationerror: query workspaces: Get "https://dev.coder.com/api/v2/workspaces?q=owner%3Ame": dial tcp: lookup dev.coder.com: no such host```
1 parent25e2146 commite5c2548

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

‎cli/root.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,11 +1060,12 @@ func cliHumanFormatError(from string, err error, opts *formatOpts) (string, bool
10601060
returnformatRunCommandError(cmdErr,opts),true
10611061
}
10621062

1063-
uw,ok:=err.(interface{Unwrap()error })
1064-
ifok {
1065-
msg,special:=cliHumanFormatError(from+traceError(err),uw.Unwrap(),opts)
1066-
ifspecial {
1067-
returnmsg,special
1063+
ifuw,ok:=err.(interface{Unwrap()error });ok {
1064+
ifunwrapped:=uw.Unwrap();unwrapped!=nil {
1065+
msg,special:=cliHumanFormatError(from+traceError(err),unwrapped,opts)
1066+
ifspecial {
1067+
returnmsg,special
1068+
}
10681069
}
10691070
}
10701071
// If we got here, that means that the wrapped error chain does not have

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp