Could you post the complete error message so that we could use the stack trace to narrow down the line of code, which raises the error?
You can post code snippets by wrapping them into three backticks ```, which makes debugging easier