#87 Correct an error handling
Merged 6 years ago by jskladan. Opened 6 years ago by gnaponie.
taskotron/ gnaponie/resultsdb develop  into  develop

@@ -229,7 +229,7 @@ 

      try:

          args = RP['get_groups'].parse_args()

      except JSONBadRequest as error:

-         return jsonify({"message": "Malformed Request: %s" % error.data['message']}), error.code

+         return jsonify({"message": "Malformed Request: %s" % error}), error.code

      except HTTPException as error:

          return jsonify(error.data), error.code

  
@@ -285,7 +285,7 @@ 

      try:

          args = RP['create_group'].parse_args()

      except JSONBadRequest as error:

-         return jsonify({"message": "Malformed Request: %s" % error.data['message']}), error.code

+         return jsonify({"message": "Malformed Request: %s" % error}), error.code

      except HTTPException as error:

          return jsonify(error.data), error.code

  
@@ -385,7 +385,7 @@ 

      try:

          args = RP['get_results'].parse_args()

      except JSONBadRequest as error:

-         retval["error"] = (jsonify({"message": "Malformed Request: %s" % error.data['message']}), error.code)

+         retval["error"] = (jsonify({"message": "Malformed Request: %s" % error}), error.code)

          return retval

      except HTTPException as error:

          retval["error"] = (jsonify(error.data), error.code)
@@ -574,7 +574,7 @@ 

      try:

          args = RP['create_result'].parse_args()

      except JSONBadRequest as error:

-         return jsonify({"message": "Malformed Request: %s" % error.data['message']}), error.code

+         return jsonify({"message": "Malformed Request: %s" % error}), error.code

      except HTTPException as error:

          return jsonify(error.data), error.code

  
@@ -730,7 +730,7 @@ 

      try:

          args = RP['get_testcases'].parse_args()

      except JSONBadRequest as error:

-         return jsonify({"message": "Malformed Request: %s" % error.data['message']}), error.code

+         return jsonify({"message": "Malformed Request: %s" % error}), error.code

      except HTTPException as error:

          return jsonify(error.data), error.code

  
@@ -765,7 +765,7 @@ 

      try:

          args = RP['create_testcase'].parse_args()

      except JSONBadRequest as error:

-         return jsonify({"message": "Malformed Request: %s" % error.data['message']}), error.code

+         return jsonify({"message": "Malformed Request: %s" % error}), error.code

      except HTTPException as error:

          return jsonify(error.data), error.code

  

The 'error' object in the handling of the JSONBadRequest error doesn't have any attribute
'data'. Trying to access to that attribute was raising another exception, so it was not
possible to understand the real error.

This must have changed in werkzeug, as I'm pretty certain it worked when I was writing the code. Well, stuff is meant to change :)

In general, this looks good, but please make sure to fix it everywhere in the code, not just in the two places. Thanks!

Ok. I'm fixing all the errors handling. But should I fix also the api_v1.py? Is that still used?

1 new commit added

  • Correct an error handling
6 years ago

@gnaponie That can be safely ignored IMO.

rebased onto 2c0eff7

6 years ago

Pull-Request has been merged by jskladan

6 years ago
Metadata