kachnitel / ridetime-server

RideTime app server
MIT License
2 stars 1 forks source link

Handle Third party errors #28

Open kachnitel opened 4 years ago

kachnitel commented 4 years ago

It is possible a trail in route doesn't exist / is hidden etc.

{
  "message":"Trail ID: 30086 not found at API!",
  "context":{
  "info":{
    "status":"error",
    "message":"Trail ID: 30086 not found at API!",
    "code":404
  },
  "detail":{
    "data":null,
    "trace":[
      {
        "file":"/home/kachna/workspace/projects/ridetime-server/src/API/Repositories/RouteRepository.php",
        "line":68,
        "function":"findWithFallback",
        "class":"RideTimeServer\\API\\Repositories\\BaseTrailforksRepository",
        "type":"->",
        "args":[30086]
      },
      {
        "file":"/home/kachna/workspace/projects/ridetime-server/src/API/Repositories/BaseTrailforksRepository.php",
        "line":71,
        "function":"populateEntity",
        "class":"RideTimeServer\\API\\Repositories\\RouteRepository",
        "type":"->",
        "args":[
          {},
          {
            "id":"318",
            "title":"ThinkBike Whistler Intermediate #2 - Cut Yer Bars/River",
            "description":"Start with one of the most well established trails in the valley and end with a signature difficult intermediate masterpiece. The route is more technical than aerobic. A few skinny bridges and wooden up n overs keep it lively in River.",
            "difficulty":1,
            "profile":{
              "distance":"9036.92",
              "alt_change":"-27.389",
              "alt_min":"641.391",
              "alt_max":"712.607",
              "alt_start":"676.923",
              "alt_end":"649.534",
              "alt_climb":"218.321",
              "alt_descent":"-245.71",
              "grade":"-0.303",
              "grade_max":"-23.589",
              "grade_min":"23.603",
              "dst_climb":"3796.53",
              "dst_descent":"3931.53",
              "dst_flat":"1308.86"
            },
            "location":"1503",
            "trails":[
                "6923",
                "30086",
                "6923",
                "6874",
                "1666"
            ]
          }
        ]
      },
      {
        "function":"upsert",
        "class":"RideTimeServer\\API\\Repositories\\BaseTrailforksRepository",
        "type":"->",
        "args":[
          {
            "id":"318",
            "rid":"1503",
            "title":"ThinkBike Whistler Intermediate #2 - Cut Yer Bars/River",
            "difficulty":"4",
            "description":"Start with one of the most well established trails in the valley and end with a signature difficult intermediate masterpiece. The route is more technical than aerobic. A few skinny bridges and wooden up n overs keep it lively in River.",
            "activitytypes":[],
            "region_index":{
              "country":"3000",
              "region1":"0",
              "prov":"3002",
              "region2":"3004",
              "region3":"7886",
              "city":"3010",
              "ridingarea":"1503",
              "wos_country":"35",
              "wos_prov":"2",
              "wos_city":"255",
              "bottom":"ridin..."

Need a solution to prevent an error while the client may just show a generic "Trail not found" in place of the missing item.

Originally posted by @kachnitel in https://github.com/kachnitel/ridetime-server/issues/26#issuecomment-554283106

kachnitel commented 4 years ago

Could return errors as a part of API response, and let the app deal with it.