Problem Solved.
The problem is with string replace function in some other function. I am using the string replace function with regular expression as input to replace function. The regular expression was incorrect due which i am getting the above error.
That’s really weird, at least GAS should give some proper error.