Created
August 12, 2016 19:23
-
-
Save achille-roussel/b83872776e84ad8f957b017e1f0ff4a8 to your computer and use it in GitHub Desktop.
Go Inline Interfaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func errorTypeOf(err error) errorType { | |
if err == nil { | |
return errorNone | |
} | |
switch e := err.(type) { | |
case interface { | |
Timeout() bool | |
}: | |
if e.Timeout() { | |
return errorTimeout | |
} | |
case interface { | |
Temporary() bool | |
}: | |
if e.Temporary() { | |
return errorTemporary | |
} | |
} | |
return errorFatal | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment