Would a type switch do what you want ? err := fn() switch err := err.(type) { case nil: // all good case *MyCustomError: // do something custom default: // unexpected error }
On Saturday, 26 November 2016 05:07:55 UTC+11, Parveen Kumar wrote: > > Hi Team, > > I want to catch my custom error being returned from various methods and > based on their type i want to return http error code. is ther any generic > way? > > Regards, > Parveen Kumar > -- 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.