SERVER-16190 Add hasFailed() function to JSThreadConfig.

Allows the caller to detect if the JSThread has thrown a JS or C++
exception, without calling join() on the thread.