try:
    # Run your setup code that may fail
except Exception as e:
    import traceback
    nuke.tprint(traceback.format_exc())  # Just in case
    msg = 'ERROR: %s' % e
    if nuke.GUI:
        nuke.message(msg)
    else:
        nuke.tprint(msg)


-Nathan



From: Mathias Möhl 
Sent: Wednesday, March 12, 2014 12:47 AM
To: nuke-python@support.thefoundry.co.uk 
Subject: Re: [Nuke-python] error messages in init.py

Thank you for the help, Diogo. 
But what to in in the except?

In a terminal session I probably want to print() the error message, but in a 
GUI session I rather want to nuke.message() it. Is there any way to distinguish 
between the two?

Cheers,
Mathias

On 12 Mar 2014, at 00:00, Diogo Girondi <diogogiro...@gmail.com> wrote:


  Using "Try/except" I guess, using "raise" directly will do just that. 

  Cheers,
  Diogo



  On Tue, Mar 11, 2014 at 10:18 AM, Mathias Möhl <i...@mamoworld.com> wrote:


    Hi,

    what’s the correct way to raise any errors in init.py and ensure that they 
are shown to the user when he is running nuke with UI?
    If I put this in my init.py


    raise Exception("Test”) 

    and launch NUKE, I just get a dialog saying "error interpreting this 
plugin” but not “Test”

    Cheers,
    Mathias


----------------------------------------------------------------------------

    mamoworld.com
    simplify your cgi
    Dr. Mathias Möhl
    Marlow 52 , 18551 Sagard, Germany
    Phone +49 (0)38302 - 88 75 61
    i...@mamoworld.com




  _______________________________________________
  Nuke-python mailing list
  Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
  http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python



--------------------------------------------------------------------------------

mamoworld.com
simplify your cgi
Dr. Mathias Möhl
Marlow 52 , 18551 Sagard, Germany
Phone +49 (0)38302 - 88 75 61
i...@mamoworld.com




--------------------------------------------------------------------------------
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to