raising error does not prevent try-except clause to get executed?
<p>I've got surprised while testing a piece of code that looked a bit like that:</p>

<pre><code>if x:
    try:
           obj = look-for-item-with-id==x in a db
           if obj is None:
               # print debug message 
               raise NotFound('No item with this id')
           return obj
    except Exception, e:
        raise Error(e.message)
</code></pre>

<p>I expected that if there was no item with a provided id (x) in a db, the NotFound exception would be raised. But instead, after getting to if clause and  printing debug message it gets to the except clause and raises the Exception (exc message is Item not found...). Could someone be so kind and enlighten me here?</p>

<p>if obj is array please check if length or count of items is zero
this mean obj not none but not contain items</p>

python exception try-except raise