Fix set logic to check for error code on failure.
Merge pull request #11 from robinmalburn/master

Fix set logic to check for error code on failure.