SpaceTradersAPI / issues-and-suggestions

16 stars 1 forks source link

Make errors more digestible by automated systems and clients #87

Closed ericgroom closed 1 year ago

ericgroom commented 3 years ago

Currently errors come back in the form of:

{
  "error": {
    "message": "A message",
    "code": 3001
  }
}

There are two things I want to suggest:

  1. Documentation on the different error codes.
  2. Potentially adding additional fields that are easy to parse.

I think the first is self explanatory.

The second would be very nice for those of us writing wrappers and SDKs which are used in automated systems. For instance if I'm trying to create a flight plan and don't have enough fuel I get this back:


"error": {
   "code": 3001,
   "message": "Ship has insufficient fuel for flight plan. You require 41 more FUEL"
}

Which is great if you yourself see the message, but I think there should be an additional field such as "fuel_missing": 41 so that an automated system could easily recover from the error without having to parse a string for the fuel.

thebrubaker commented 3 years ago

I like this idea. We could add a property for data (or a better suggested prop name) that will contain values for the context of the error.