MCPcopy Create free account
hub / github.com/cli/cli / printError

Function printError

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

Source from the content-addressed store, hash-verified

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