api: add some basic error handling