External interface error handling

Error handling have been updated with setting error codes for exported classes.
Merge pull request #4 from evmarkov/master

External interface error handling