You need to provide a test case because its not very clear what you are doing in order to have that exception thrown.