p2or
6/17/2016 - 4:43 PM

blender-supressOperatorOutput-II.py

# for http://blender.stackexchange.com/questions/56087/check-if-an-operation-can-be-applied-without-runtime-errors

import bpy

if bpy.ops.mesh.fill_grid.poll():
    print("correct context")
    
    try:
        bpy.ops.mesh.fill_grid()
    except RuntimeError as exception:
        error = "\n".join(exception.args)
        print("error:", error)

else:
    print ("incorrect context")