Fixed API

Previously API always reported errors, resulting in an empty printed
message.