| 279 | } |
| 280 | |
| 281 | func 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 | |
| 303 | func authRecoveryCommand(cfg gh.Config, httpErr api.HTTPError) string { |
| 304 | if httpErr.RequestURL == nil { |