12-20-2024, 08:26 PM
(12-20-2024, 05:17 PM)david Wrote: Another of my stupid questions!!!
In my website photos plug-in, if I test for missing data input, how do I get it to print only my gimp message and exit.
I have been searching for this all day and tried numerous things without success.
Most of the things I have tried add additional error messages.
David.
If you exit properly there shouldn't be any. My plugins are usually architected like this:
Code:
import traceback
def pluginImplementation(image,etc...):
image.undo_group_start() # so that whatever happens, only one single Ctrl-Z to revert
gimp.context_push() # if the code alters the context, otherwise omitted
try: # start Try/except block
# implementation code goes here. Can call functions
if some_error_case:
raise Exception('This message will be displayed to the user')
# some more implmentation code
except Exception as e: # catch any exception raised by the code
pdb.gimp_message(e.args[0]) # Error message to the user
print traceback.format_exc() # Traceback to terminal for developper
gimp.context_pop() # if there was a push() at the top
image.undo_group_end() # close the undo group (done whatever happened before, error or success)