attr: add default error reasons

This commit is contained in:
Aleksandr Razumov
2016-05-08 01:14:18 +03:00
parent 55ce3c0071
commit 6905ed655c
2 changed files with 41 additions and 0 deletions

34
attribute_errorcode.go Normal file
View File

@@ -0,0 +1,34 @@
package stun
// ErrorCode is code for ERROR-CODE attribute.
type ErrorCode int
// Possible error codes.
const (
CodeTryAlternate ErrorCode = 300
CodeBadRequest ErrorCode = 400
CodeUnauthorised ErrorCode = 401
CodeUnknownAttribute ErrorCode = 420
CodeStaleNonce ErrorCode = 428
CodeServerError ErrorCode = 500
)
// Reason returns recommended reason string.
func (c ErrorCode) Reason() string {
switch c {
case CodeTryAlternate:
return "Try Alternate"
case CodeBadRequest:
return "Bad Request"
case CodeUnauthorised:
return "Unauthorised"
case CodeUnknownAttribute:
return "Unknown attribute"
case CodeStaleNonce:
return "Stale Nonce"
case CodeServerError:
return "Server Error"
default:
return "Unknown Error"
}
}