bin/api: handle errors better