I'm trying to create Refit library for my APIs.
I wanted to throw ApiExeption whenever status code received is other than 200 and 207.
public interface IServiceAPIs{
[Post("/api/users/register")]
Task<HttpResponseMessage> PostData([Header]string auth,RegisterUserRequest registerUserRequest);
}
and in my implementation class:
try {
var response = service.PostData(auth,registerUsers);
if(!response.IsSuccessStatusCode){
throw new ApiException(); // Here I'm not able to find how to throw this exception
}
} catch(ApiException Ex) {
log.write(ex);
}
How can I throw exception.?
Thanks in advance.