Adds some missing error handling logic.

Adds error handling for when no rows are returned from the sql query