Here's a catchall, which will print out whatever the original error was

try:
        1/0
except Exception, e:
        print 'Error: %s' % e

#Error: integer division or modulo by zero


On 18-May-09, at 8:56 AM, frostfyre wrote:

> try:
>     myfunc()
> except:
>     pass
>
> will provide the same "fire and forget" functionality as  
> catch(`myFunc()`); would in MEL. You can also catch specific  
> exception types to do advanced error handling from here.
>
> try:
>     myfunc(some_arg)
> except TypeError:
>     print "myFunc() requires argument of type foo.\n myFunc() failed."
>     pass
>
> In this example, the user is notified that the function failed, and  
> given the reason, while still allowing whatever called that function  
> to continue.
>
> Hope this helps
>
> -Paul
>
>
>
> On Mon, May 18, 2009 at 8:22 AM, ynedelin <[email protected]> wrote:
>
> what is a way to catch error when in python similar to MEL?
>
> thanks
> Yury
>
>
>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

  • ... ynedelin
    • ... Richard Kazuo
    • ... kurian os ™ ®കോപ്പിയടിച്ചാല്©ഗോതമ്പുണ്ട!
    • ... frostfyre
      • ... yury nedelin
      • ... Justin Rosen

Reply via email to