package apierrors // APIError is the base API error type. type APIError struct { Success bool `json:"success"` StatusCode int `json:"errorcode"` Description string `json:"description"` PolrStyle bool `json:"-"` } // Generic errors (Pomf style) var ( // BadToken is a 401 unauthorized error. BadToken = APIError{false, 401, "bad token", false} // Unauthorized is a 401 unauthorized error. Unauthorized = APIError{false, 401, "unauthorized", false} // InvalidJSONPayload is a 400 bad request error. InvalidJSONPayload = APIError{false, 400, "invalid JSON payload", false} // EmailOrUsernameNotSupplied is a 400 bad request error. EmailOrUsernameNotSupplied = APIError{false, 400, "email or username not provided", false} // InvalidEmailOrUsername is a 400 bad request error. InvalidEmailOrUsername = APIError{false, 400, "invalid email or username", false} // UserExists is a 409 conflict error. UserExists = APIError{false, 409, "user with that email or username already exists", false} // InvalidOffsetOrLimit is a 400 bad request error. InvalidOffsetOrLimit = APIError{false, 400, "invalid offset or limit query paramters", false} // OffsetTooLarge is a 400 bad request error. LimitTooLarge = APIError{false, 400, "limit is too big", false} // NoObjectFound is a 404 not found error. NoObjectFound = APIError{false, 404, "no object found", false} // AlreadyDeleted is a 410 gone error. AlreadyDeleted = APIError{false, 410, "already deleted", false} // InsufficientTokens is a 429 too many requests error. InsufficientTokens = APIError{false, 429, "too many requests", false} // BadFileID is a 400 bad request error. BadFileID = APIError{false, 400, "bad file ID", false} // InvalidBanFileReason is a 400 bad request error. InvalidBanFileReason = APIError{false, 400, "invalid reason, must be an integer from 0 to 3 inclusive", false} // InvalidBanFileMalwareName is a 400 bad request error. InvalidBanFileMalwareName = APIError{false, 400, "malware_name is required when reason is 1 (malware)", false} // FileIsAlreadyBanned is a 409 conflict error. FileIsAlreadyBanned = APIError{false, 409, "file is already banned", false} // CannotQuarantineDueToNoMatchingObjects is a 404 not found error. CannotQuarantineDueToNoMatchingObjects = APIError{false, 404, "cannot quarantine due to no matching objects", false} // FileIsNotBanned is a 404 not found error. FileIsNotBanned = APIError{false, 404, "specified file is not banned", false} // InvalidObjectFilter is a 400 bad request error. InvalidObjectFilter = APIError{false, 400, `invalid filter, must be "", "files" or "links"`, false} ) // Pomf errors var ( // ContentLengthRequired is a 411 length required error. ContentLengthRequired = APIError{false, 411, "Content-Length header required", false} // InvalidContentLength is a 400 bad request error. InvalidContentLength = APIError{false, 400, "invalid Content-Length header, should be an integer", false} // BodyTooLarge is a 413 payload too large error. BodyTooLarge = APIError{false, 413, "request body too large, DO NOT reattempt upload", false} // NoFilesInRequest is a 400 bad request error. NoFilesInRequest = APIError{false, 400, "no files[] present in multipart/form-data body", false} // TooManyFilesInRequest a 400 bad request error. TooManyFilesInRequest = APIError{false, 400, "too many files[] present in multipart/form-data body", false} // InternalServerError is a 500 internal server error. InternalServerError = APIError{false, 500, "internal server error", false} // FileIsBanned is a 409 conflict error. FileIsBanned = APIError{false, 409, "file is banned", false} ) // Polr errors var ( // UnauthorizedPolr is a 401 unauthorized error. UnauthorizedPolr = APIError{false, 400, "unauthorized", true} // InvalidPolrAction is a 400 bad request error. InvalidPolrAction = APIError{false, 400, `invalid action, must be "shorten"`, true} // InvalidPolrURL is a 400 bad request error. InvalidPolrURL = APIError{false, 400, "invalid URL", true} // InternalServerErrorPolr is a 500 internal server error. InternalServerErrorPolr = APIError{false, 500, "internal server error", true} )