* Chris Hopkins <cbehopk...@gmail.com> [171002 10:52]: > out, err := os.Create(potential_file_name) > switch t := err.(type) { > case *os.PathError: > switch t.Err { > case os.ErrNotExist: > log.Fatal("Invalid filename", potential_file_name) > case os.ErrInvalid: > log.Fatal("Invalid argument", potential_file_name) > default :
I think what you are missing is that t.Err is almost certainly a syscall.Errno, which you can type-switch and then use directly: switch en := t.Err.(type) { case syscall.Errno: switch en { case syscall.EISDIR: ... } default: ... // I don't think os.Create will ever return an error that // isn't syscall.Errno wrapped as an os.PathError. } Of course, this is OS dependent. However, I think EISDIR is defined for all supported architectures. > switch t.Err.Error(){ > case "is a directory": > // Case we are trying to catch > return > default: > log.Fatalf("Unknown > os.PathError\n\"%s\"\n%v\n,Type:%t\nDir:%s\nUrl:%s\n", potential_file_name, > t.Err, t.Err, dir_str, fetch_url) > } > } > case nil: > // nothing to see here > default: > log.Fataf("Error is of type %T,n", err) > } ...Marvin -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.