diff options
author | Collin Guarino <collin.guarino@gmail.com> | 2016-01-30 12:52:10 -0500 |
---|---|---|
committer | Collin Guarino <collin.guarino@gmail.com> | 2016-01-30 12:52:10 -0500 |
commit | 6665737855d6e30628591d71f6c32b6ce462b90d (patch) | |
tree | 04c0d8bd6308e815967242c587f7337da3bd79ff /bridge.go | |
parent | 779dcafebdca3282c5bcd8855ab006ab7328e49c (diff) |
Added generic errors from Hue doc site.
Diffstat (limited to 'bridge.go')
-rw-r--r-- | bridge.go | 61 |
1 files changed, 51 insertions, 10 deletions
@@ -38,6 +38,57 @@ type BridgeInfo struct { } `xml:"root"` } +// Error Struct +// http://www.developers.meethue.com/documentation/error-messages +type Error struct { + ID int + Description string + Details string +} + +// Error Return Values +// http://www.developers.meethue.com/documentation/error-messages +var ( + // Generic Errors + ErrAuth = Error{1, "Unauthorized User", + `This will be returned if an invalid username is used in the request, + or if the username does not have the rights to modify the resource.`} + ErrJson = Error{2, "Body contains invalid JSON.", + "This will be returned if the body of the message contains invalid JSON."} + ErrResource = Error{3, "Resource, <resource>, not available.", + `This will be returned if the addressed resource does not exist. + E.g. the user specifies a light ID that does not exist.`} + ErrMethod = Error{4, "Method, <method_name>, not available for resource, <resource>", + `This will be returned if the method (GET/POST/PUT/DELETE) + used is not supported by the URL e.g. DELETE is not + supported on the /config resource`} + ErrParamMissing = Error{5, "Missing parameters in body.", `Will be returned if + required parameters are not present in the message body. The presence + of invalid parameters should not trigger this error as long as all + required parameters are present.`} + ErrParamNA = Error{6, "Parameter, <parameter>, not available.", + `This will be returned if a parameter sent in the message body does + not exist. This error is specific to PUT commands; invalid parameters + in other commands are simply ignored.`} + ErrParamInvalid = Error{7, "Invalid value, <value>, for parameter, <parameter>", + `This will be returned if the value set for a parameter is of the + incorrect format or is out of range.`} + ErrParamStatic = Error{8, "Parameter, <parameter>, is not modifiable", + `This will be returned if an attempt to modify a read only + parameter is made.`} + ErrItemOverflow = Error{11, "Too many items to list.", + "List in request contains too many items"} + ErrPortalConn = Error{12, "Portal connection required.", + `Command requires portal connection. + Returned if portalservices is “false“ or the portal connection is down`} + ErrorInternal = Error{901, "Internal error, <error code>", + `This will be returned if there is an internal error in the + processing of the command. This indicates an error in the + bridge, not in the message being sent.`} + + // TODO: Command specific error numbers and descriptions +) + // NewBridge defines hardware that is compatible with Hue. func NewBridge(ip string, username string) *Bridge { bridge := Bridge { @@ -76,16 +127,6 @@ func GetBridgeInfo(self *Bridge) { self.Info = *data } -// Error Struct - REST Error Response Format -// http://www.developers.meethue.com/documentation/error-messages -type Error struct { - response struct { - Type string `xml:"type"` - Address string `xml:"address"` - Description string `xml:"description"` - } `xml:"error"` -} - // CreateUser posts to ./api on the bridge to create a new whitelisted user. // If the button on the bridge was not pressed then _____todo_____ func CreateUser(bridge *Bridge, deviceType string) (string, error) { |