Skip to content

Commit 0862d19

Browse files
committed
Complete Info method and increase error detection for HasErrorOccurred
1 parent e0120e5 commit 0862d19

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

SSLLWrapper/ApiService.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,20 @@ public ApiService(string apiUrl)
6262
public InfoModel Info()
6363
{
6464
var infoModel = new InfoModel();
65+
66+
// Building request model
6567
var requestModel = _requestModelHelper.InfoProperties(ApiUrl, "info");
6668

6769
try
6870
{
71+
// Making Api request and gathering response
6972
var webResponse = _api.MakeGetRequest(requestModel);
7073
var webResult = _webResponseHelper.GetResponsePayload(webResponse);
7174

72-
// ** TO DO - Check for error before converting to model. Expand model to include error properties?
75+
// Trying to bind result to model
7376
infoModel = JsonConvert.DeserializeObject<InfoModel>(webResult, JsonSerializerSettings);
77+
infoModel.Headers.statusCode = _webResponseHelper.GetStatusCode(webResponse);
78+
infoModel.Headers.statusDescription = _webResponseHelper.GetStatusDescription(webResponse);
7479

7580
if (infoModel.engineVersion != null)
7681
{
@@ -83,6 +88,9 @@ public InfoModel Info()
8388
infoModel.Errors.Add(new Error { message = ex.ToString() });
8489
}
8590

91+
// Checking if errors have occoured either from ethier api or wrapper
92+
if (infoModel.Errors.Count != 0 && !infoModel.HasErrorOccurred) { infoModel.HasErrorOccurred = true;}
93+
8694
return infoModel;
8795
}
8896

@@ -125,6 +133,9 @@ public AnalyzeModel Analyze(string host, Publish publish, ClearCache clearCache,
125133
analyzeModel.Errors.Add(new Error {message = ex.ToString()});
126134
}
127135

136+
// Checking if errors have occoured either from ethier api or wrapper
137+
if (analyzeModel.Errors.Count != 0 && !analyzeModel.HasErrorOccurred) { analyzeModel.HasErrorOccurred = true; }
138+
128139
return analyzeModel;
129140
}
130141

0 commit comments

Comments
 (0)