I am designing a RESTful API using Python and Flask. As expected, the API needs to receive an API request and return data if all goes well, but in the instance of an error, it n
You could use abort(http_code) to return an appropriate http code to the client or just raise a non-http exception. And use @app.errorhandler()
decorator to provide a custom handler for http errors and arbitrary exceptions. You could also use an ordinary try/except block where you are ready to handle an exception. Python is not Go you can use exceptions.
Maybe the Flask API is more suitable for your needs, as it is particularly designed for RESTful APIs.
It has better exception handling than Flask, see: http://www.flaskapi.org/api-guide/exceptions/