def testParameterInvalidWhenParameterChangedRaises( self ) :

		class InvalidValueRaiser( IECore.Parameterised ) :

			def __init__( self ) :

				IECore.Parameterised.__init__( self, "" )

				self.parameters().addParameters(

					[

						IECore.IntParameter(
							name = "driver",
							description = "",
							defaultValue = 0,
						),

					],

				)

				self.changes = []

			def parameterChanged( self, parameter ) :

				# this puts the parameter in a state where its value
				# is not valid.
				parameter.setValue( IECore.StringData( "oh dear" ) )
				# then when we raise here, a further exception will
				# occur when the invalid parameter value is discovered
				# during the application of parameter changes to the plugs.
				raise RuntimeError( "Ooops!" )

		c = InvalidValueRaiser()

		ph = GafferCortex.ParameterisedHolderNode()
		ph.setParameterised( c )

		with IECore.CapturingMessageHandler() as mh :
			# We want the original exception to be the visible one.
			self.assertRaisesRegexp( RuntimeError, "Ooops!", ph["parameters"]["driver"].setValue, 1 )
		# And we want the secondary exception to be reported as a message.
		self.assertEqual( len( mh.messages ), 1 )
		self.assertTrue( "Value is not an instance of \"IntData\"" in mh.messages[0].message )
dataset/ETHPy150Open ImageEngine/gaffer/python/GafferCortexTest/ParameterisedHolderTest.py/ParameterisedHolderTest.testParameterInvalidWhenParameterChangedRaises/original