Added additional bad input error handling.

Change-Id: I1959bbdd7735efbc7110cd6ef22e29deadd4ea41
Reviewed-on: http://review.couchbase.org/37489
Reviewed-by: Mark Nunberg <mnunberg@haskalah.org>
Tested-by: Brett Lawson <brett19@gmail.com>