package apierrors
import "github.com/mesos/mesos-go/api/v1/lib/httpcli/apierrors"
Index ¶
- Constants
- Variables
- func FromResponse(res *http.Response) error
- type Code
- func (code Code) Error(details string) error
- func (code Code) IsError() bool
- func (code Code) Matches(err error) bool
- type Error
Constants ¶
const ( // MsgNotLeader is returned by Do calls that are sent to a non leading Mesos master. MsgNotLeader = "call sent to a non-leading master" // MsgAuth is returned by Do calls that are not successfully authenticated. MsgAuth = "call not authenticated" // MsgUnsubscribed is returned by Do calls that are sent before a subscription is established. MsgUnsubscribed = "no subscription established" // MsgVersion is returned by Do calls that are sent to an incompatible API version. MsgVersion = "incompatible API version" // MsgMalformed is returned by Do calls that are malformed. MsgMalformed = "malformed request" // MsgMediaType is returned by Do calls that are sent with an unsupported media type. MsgMediaType = "unsupported media type" // MsgRateLimit is returned by Do calls that are rate limited. This is a temporary condition // that should clear. MsgRateLimit = "rate limited" // MsgUnavailable is returned by Do calls that are sent to a master or agent that's in recovery, or // does not yet realize that it's the leader. This is a temporary condition that should clear. = "mesos server unavailable" // MsgNotFound could happen if the master or agent libprocess has not yet set up http routes. MsgNotFound = "mesos http endpoint not found" CodeNotLeader = Code(http.StatusTemporaryRedirect) CodeNotAuthenticated = Code(http.StatusUnauthorized) CodeUnsubscribed = Code(http.StatusForbidden) CodeIncompatibleVersion = Code(http.StatusConflict) CodeMalformedRequest = Code(http.StatusBadRequest) CodeUnsupportedMediaType = Code(http.StatusNotAcceptable) CodeRateLimitExceeded = Code(http.StatusTooManyRequests) = Code(http.StatusServiceUnavailable) CodeNotFound = Code(http.StatusNotFound) MaxSizeDetails = 4 * 1024 // MaxSizeDetails limits the length of the details message read from a response body )
Variables ¶
var CodesIndicatingSubscriptionLoss = func(codes ...Code) map[Code]struct{} { result := make(map[Code]struct{}, len(codes)) for _, code := range codes { result[code] = struct{}{} } return result }( CodeUnsubscribed, )
CodesIndicatingSubscriptionLoss is a set of apierror.Code entries which each indicate that the event subscription stream has been severed between the scheduler and mesos. It's respresented as a public map variable so that clients can program additional error codes (if such are discovered) without hacking the code of the mesos-go library directly.
var ( // ErrorTable maps HTTP response codes to their respective Mesos v1 API error messages. ErrorTable = map[Code]string{ CodeNotLeader: MsgNotLeader, CodeMalformedRequest: MsgMalformed, CodeIncompatibleVersion: MsgVersion, CodeUnsubscribed: MsgUnsubscribed, CodeNotAuthenticated: MsgAuth, CodeUnsupportedMediaType: MsgMediaType, CodeNotFound: MsgNotFound, CodeMesosUnavailable: MsgUnavailable, CodeRateLimitExceeded: MsgRateLimit, } )
Functions ¶
func FromResponse ¶
FromResponse returns an `*Error` for a response containing a status code that indicates an error condition. The response body (if any) is captured in the Error.Details field. Returns nil for nil responses and responses with non-error status codes. See IsErrorCode.
Types ¶
type Code ¶
type Code int
Code is a Mesos HTTP v1 API response status code
func (Code) Error ¶
Error generates an error from the given status code and detail string.
func (Code) IsError ¶
IsError returns true for all HTTP status codes that are not considered informational or successful.
func (Code) Matches ¶
Matches returns true if the given error is an API error with a matching error code
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error captures HTTP v1 API error codes and messages generated by Mesos.
func (*Error) Error ¶
Error implements error interface
func (*Error) SubscriptionLoss ¶
SubscriptionLoss returns true if the error indicates that the event subscription stream has been severed between mesos and a mesos client.
func (*Error) Temporary ¶
Temporary returns true if the error is a temporary condition that should eventually clear.
Source Files ¶
- Version
- v0.0.11 (latest)
- Published
- May 15, 2020
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 2 hours ago –
Tools for package owners.