Is the JS code prepare handle this error condition correctly? (received null as answer)