Add API error/exception handling