Fix for Titanium compiler error

Was getting a compiler error so cleaned up the logic and moved the setting of the error message into the catch method.
Merge pull request #22 from kolchy/patch-1

Fix for Titanium compiler error