public void ConfirmNullExceptions() { var mockRequest = new Mock <IRestRequest>(); var mockResponse = new Mock <IRestResponse>(); Assert.Throws <ArgumentNullException>(() => { var t = new HttpErrorException(mockRequest.Object, null); Console.WriteLine(t); }); Assert.Throws <ArgumentNullException>(() => { var t = new HttpErrorException(null, mockResponse.Object); Console.WriteLine(t); }); }
private TResult ProcessExecution <TResult>(IRestResponse response) where TResult : class { //if the return type is not 200 throw errors if (response.StatusCode != HttpStatusCode.OK) { var excpetion = new HttpErrorException(Request, response); var eventThrow = OnExceptionThrown; if (eventThrow != null) { eventThrow(this, new UnhandledExceptionEventArgs(excpetion, FailFast)); } if (FailFast) { throw excpetion; } return(null); } //try to deserialize try { return(JsonConvert.DeserializeObject <TResult>(response.Content)); } catch (System.Exception e) { var eventThrow = OnExceptionThrown; if (eventThrow != null) { eventThrow(this, new UnhandledExceptionEventArgs(e, FailFast)); } if (FailFast) { throw; } return(null); } }