Routelandia / routelandia-server

The server backend to power the Routelandia project.
Apache License 2.0
0 stars 1 forks source link

Throw/catch errors from DB logic in entities. #27

Closed joshproehl closed 9 years ago

joshproehl commented 9 years ago

What happens when a controller requests an ID that doesn't exist?

We don't get a very sensible error currently, especially if we're calling to stations, because the call to decodeSegmentsJson fails.

The bigger picture though, is that we need a consistent way to ensure that the client receives an error they understand for ALL requests, on ALL controllers, indicating an error. (For one: they ought to be checking the HTTP status code returned, so we need to make sure we're setting that correctly.)

(As a side note: this is what tests are for.)

joshproehl commented 9 years ago

FYI, Restler seems to return errors in the following format:


{
  "error": {
    "code": 400,
    "message": "Bad Request: Invalid value specified for `request_data`"
  },
  "debug": {
    "source": "Validator.php:617 at validate stage",
    "stages": {
      "success": [
        "get",
        "route",
        "negotiate"
      ],
      "failure": [
        "validate",
        "message"
      ]
    }
  }
}

I'm not sure if the entire thing is supressed when restler is run in "production mode", or if only the debug object is. Either way, we should tap into this error reporting functionality as our method (or at least format) for sending back errors.