Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle wrong answer by agrirouter on Onboarding or Revoke Failure #144

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<PackageProjectUrl>https://github.com/DKE-Data/agrirouter-sdk-dotnet-standard</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/DKE-Data/agrirouter-sdk-dotnet-standard/blob/develop/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/DKE-Data/agrirouter-sdk-dotnet-standard</RepositoryUrl>
<PackageVersion>3.9.0</PackageVersion>
<AssemblyVersion>3.9.0</AssemblyVersion>
<PackageVersion>3.9.1</PackageVersion>
<AssemblyVersion>3.9.1</AssemblyVersion>
<Company>DKE-Data GmbH &amp; Co. KG</Company>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ public OnboardResponse Onboard(OnboardParameters onboardParameters)

if (!httpResponseMessage.IsSuccessStatusCode) {
var onboardErrorResponse = JsonConvert.DeserializeObject<OnboardErrorResponse>(result);
throw new OnboardException(httpResponseMessage.StatusCode, onboardErrorResponse.OnboardError);
throw new OnboardException(httpResponseMessage.StatusCode, onboardErrorResponse?.OnboardError ?? new OnboardError()
{
Code = "Unstructured",
Message = result
}
);
}

var onboardingResponse = JsonConvert.DeserializeObject(result, typeof(OnboardResponse));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public void Revoke(RevokeParameters revokeParameters, string privateKey)
var httpResponseMessage = _httpClient.SendAsync(httpRequestMessage).Result;

if (!httpResponseMessage.IsSuccessStatusCode) {
var onboardErrorResponse = JsonConvert.DeserializeObject<OnboardErrorResponse>(httpResponseMessage.Content.ReadAsStringAsync().Result);
var result = httpResponseMessage.Content.ReadAsStringAsync().Result;
var onboardErrorResponse = JsonConvert.DeserializeObject<OnboardErrorResponse>(result);
throw new RevokeException(httpResponseMessage.StatusCode, onboardErrorResponse.OnboardError);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<PackageProjectUrl>https://github.com/DKE-Data/agrirouter-sdk-dotnet-standard</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/DKE-Data/agrirouter-sdk-dotnet-standard/blob/develop/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/DKE-Data/agrirouter-sdk-dotnet-standard</RepositoryUrl>
<PackageVersion>3.9.0</PackageVersion>
<AssemblyVersion>3.9.0</AssemblyVersion>
<PackageVersion>3.9.1</PackageVersion>
<AssemblyVersion>3.9.1</AssemblyVersion>
<Company>DKE-Data GmbH &amp; Co. KG</Company>
</PropertyGroup>

Expand Down
Loading