server: add error handling