Python: Custom Exception Class deriving from ValueError
<p>My question seems rather simply, but I didn't find any post to this particular issue. I need my own custom exception class deriving from ValueError to print the expected type (standard error msg) as well as the type that was entered (with custom text).</p>

<pre><code>class MyOwnException(ValueError):
  ...

try:
    raise MyOwnException ( int('str') ) #not sure what to do here, as I only want to
                                        #raise the exception if incorrect value type
except MyOwnException as e:
        print "Error: Expected type", e.expType() #int
        print "Error: Entered type", e.entType()  #string
</code></pre>

<p>To add to the above and raising my custom exception via the built-in ValueError:</p>

<pre><code>class MyOwnException(ValueError):
  def __init__(self, value):
    self.value = value
  print "Error: Expected type", type(self.value) #int
  print "Error type", self.value #how to return expected value type?

try:
    int('str')               
except ValueError as e:
    raise MyOwnException(e)
</code></pre>

<p>I would very much appreatiate any help in this regard. Thanks very much!
Cheers, Manuel</p>
