Also possible there's some error handling code that was not closed off properly that was run before your function.
Trace through the execution, see if there is a statement like:
On Error Resume Next
Then check if that exception handling block is closed off property. Usually you'll need a statement like
On Error GoTo 0 (or some other line number), along with like Err.Clear() to clear the error condition.
Yeah, VBScript is a pain in the *** to do error handling correctly. This makes it a horrible language for implementing high level frameworks.