fixed issue with throwing error but not catching it in API