title: How to return a non default reply in AWS API gateway without raising an Exception?
body: <p>I'm running a service that uses the AWS API Gateway. There is an endpoint that is integrated using a lambda function written in Python. This endpoint has several different response codes, for example, 200, 201, 400, 404. </p>
  
  <p>I'm aware we can generate different response codes by raising an exception and catching the error regex in API Gateway. An example in python would be:</p>
  
  <pre><code>def lambda_handler(event, context):
      raise Exception('404_not_found')
  </code></pre>
  
  <p>And then configure in the API Gateway in following way: </p>
  
  <p><img src="https://i.imgur.com/MpxQX2d.png" alt="gateway config"></p>
  
  <p>This will then return a 404 response code. The problem with this approach is that my log will be full of errors. Even when I want to throw a different response than the default one, like a 201 in this case, I believe I would have to raise an Exception.</p>
  
  <p>This results in difficult monitoring, where I have a bunch of exceptions in my logs which are actually just natural behavior. My question, therefore, is if I can generate a non default response without raising an Exception when using Python lambdas and the API Gateway?</p>