JSON Cloud error messages inconsistent

Hi I’m new to this so please be patient :smile:

I’ve been checking the cloud error messages in different situations and they are not very consistent for example:

// ----------- Device turned off -----------------

{
  "error": "Timed out."
}

// ------------ incorrect variable --------------
{
  "ok": false,
  "error": "Variable not found"
}
// -------------------- incorrect device ID --------------
{
  "error": "Permission Denied",
  "info": "I didn't recognize that device name or ID, try opening https://api.particle.io/v1/devices?access_token=MY_ACCESS_TOKEN"
}
// -------------------- incorrect access Token --------------
{
  "error": "invalid_token",
  "error_description": "The access token provided is invalid."
}

Device not found and incorrect variable both return the error key, so I could look for this to check for errors, but incorrect device ID and incorrect access token both return extended error information, but incorrect device ID returns extended info in the key "info" and incorrect access token returns it in the key "error_description".

I can code for this, but it makes it a messy program.

It would be nice if extended error information was always available when an error occurs in the return JSON string and used the same key name to point to it.

Thanks for reading…

Steve

1 Like

Hi Steve,

Thanks for posting! We’re collecting notes like this for when we prepare the v2 branch of the api. There’s always a bit of a fine balance with existing APIs, since we need to be careful not to change anything too dramatically that might impact existing apps, but definitely something we’ll keep in mind for the next version. :slight_smile:

Thanks!
David

Hi David

Thanks for your quick reply. I’ve had a further think about this and maybe if you included a numeric error code where, for example 0 is no error then a bunch of error numbers for different situations.

Then hopefully the addition of the another key/value will not break existing software.

Thanks for reading…

Steve