title: Is there a way to group all of my Exception cases into a single class?
body: <p>I am building an API for post, get, etc a file and want to handle all possible exceptions that may occur. How can I go about grouping all exceptions into a single class which encapsulates all the cases which are being called repeatedly?</p>
  <p>Ex:</p>
  <pre><code>except KeyError as e:
      log.info(e, exc_info=True)
      resp_dict = {'status': 'unsuccessful', 'message': 'Key error', 'data': ''}
      response = Response(response=json.dumps(resp_dict), status=400, mimetype='application/json',
                                  headers=base_headers)
  except FileExistsError as e:
      log.info(e, exc_info=True)
      resp_dict = {'status': 'unsuccessful', 'message': 'File already exists', 'data': ''}
      response = Response(response=json.dumps(resp_dict), status=400, mimetype='application/json',
                                  headers=base_headers)
  </code></pre>
  <p>These are being called repeatedly in many places. How can I go forward in this case?</p>