Api router error handling improvements