If there is an error, you should raise an exception. Error codes should only be used in protocols and languages that don't support exceptions.