MCPcopy
hub / github.com/cli/cli / printError

Function printError

internal/ghcmd/cmd.go:281–301  ·  view source on GitHub ↗
(out io.Writer, err error, cmd *cobra.Command, debug bool)

Source from the content-addressed store, hash-verified

279}
280
281func printError(out io.Writer, err error, cmd *cobra.Command, debug bool) {
282 var dnsError *net.DNSError
283 if errors.As(err, &dnsError) {
284 fmt.Fprintf(out, "error connecting to %s\n", dnsError.Name)
285 if debug {
286 fmt.Fprintln(out, dnsError)
287 }
288 fmt.Fprintln(out, "check your internet connection or https://githubstatus.com")
289 return
290 }
291
292 fmt.Fprintln(out, err)
293
294 var flagError *cmdutil.FlagError
295 if errors.As(err, &flagError) || strings.HasPrefix(err.Error(), "unknown command ") {
296 if !strings.HasSuffix(err.Error(), "\n") {
297 fmt.Fprintln(out)
298 }
299 fmt.Fprintln(out, cmd.UsageString())
300 }
301}
302
303func authRecoveryCommand(cfg gh.Config, httpErr api.HTTPError) string {
304 if httpErr.RequestURL == nil {

Callers 2

MainFunction · 0.70
Test_printErrorFunction · 0.70

Calls 1

ErrorMethod · 0.45

Tested by 1

Test_printErrorFunction · 0.56