Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tDevkit
Manage
Activity
Members
Plan
Wiki
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Digital Twin
Twinzo
tDevkit
Commits
59a176df
Commit
59a176df
authored
3 years ago
by
Daniel Andrášik
Browse files
Options
Downloads
Patches
Plain Diff
- fix test
- fix error handling
parent
6accd71c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
SDK/Connection/DevkitConnector.cs
+16
-22
16 additions, 22 deletions
SDK/Connection/DevkitConnector.cs
SDK/SDK.csproj
+1
-1
1 addition, 1 deletion
SDK/SDK.csproj
Test/Test/V3/Devices.cs
+2
-2
2 additions, 2 deletions
Test/Test/V3/Devices.cs
with
19 additions
and
25 deletions
SDK/Connection/DevkitConnector.cs
+
16
−
22
View file @
59a176df
...
...
@@ -119,29 +119,23 @@ namespace SDK
protected
async
Task
HandleError
(
HttpResponseMessage
response
)
{
var
stringContent
=
await
response
.
Content
.
ReadAsStringAsync
();
try
{
switch
(
response
.
StatusCode
)
{
case
System
.
Net
.
HttpStatusCode
.
BadRequest
:
case
System
.
Net
.
HttpStatusCode
.
Unauthorized
:
case
System
.
Net
.
HttpStatusCode
.
PaymentRequired
:
case
System
.
Net
.
HttpStatusCode
.
Forbidden
:
case
System
.
Net
.
HttpStatusCode
.
NotFound
:
case
System
.
Net
.
HttpStatusCode
.
MethodNotAllowed
:
case
System
.
Net
.
HttpStatusCode
.
InternalServerError
:
var
prettyJson
=
JsonSerializer
.
Serialize
(
stringContent
,
new
JsonSerializerOptions
()
{
WriteIndented
=
true
});
throw
new
ServerResponseException
(
prettyJson
);
default
:
throw
new
ServerResponseException
(
stringContent
);
}
}
catch
(
Exception
)
switch
(
response
.
StatusCode
)
{
throw
new
ServerResponseException
(
stringContent
);
case
System
.
Net
.
HttpStatusCode
.
BadRequest
:
case
System
.
Net
.
HttpStatusCode
.
Unauthorized
:
case
System
.
Net
.
HttpStatusCode
.
PaymentRequired
:
case
System
.
Net
.
HttpStatusCode
.
Forbidden
:
case
System
.
Net
.
HttpStatusCode
.
NotFound
:
case
System
.
Net
.
HttpStatusCode
.
MethodNotAllowed
:
case
System
.
Net
.
HttpStatusCode
.
InternalServerError
:
var
prettyJson
=
JsonSerializer
.
Serialize
(
stringContent
,
new
JsonSerializerOptions
()
{
WriteIndented
=
true
});
throw
new
ServerResponseException
(
prettyJson
);
default
:
throw
new
ServerResponseException
(
stringContent
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
SDK/SDK.csproj
+
1
−
1
View file @
59a176df
...
...
@@ -5,7 +5,7 @@
<TargetFramework>net5.0</TargetFramework>
<AssemblyVersion>2021.6.28.25</AssemblyVersion>
<FileVersion>2021.6.28.25</FileVersion>
<Version>4.2.
0
</Version>
<Version>4.2.
1
</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
...
...
This diff is collapsed.
Click to expand it.
Test/Test/V3/Devices.cs
+
2
−
2
View file @
59a176df
...
...
@@ -17,7 +17,7 @@ using SDK.Exceptions;
namespace
Test
{
[
TestClass
]
public
class
Area
Test
public
class
Device
Test
{
protected
const
string
URL
=
"http://localhost:8000"
;
private
const
string
PATH_BASE
=
"/api/v3/devices"
;
...
...
@@ -60,9 +60,9 @@ namespace Test
Message
=
"Error"
};
server
.
Reset
();
server
.
Given
(
Request
.
Create
().
WithPath
(
PATH_BASE
).
UsingGet
())
.
RespondWith
(
Response
.
Create
().
WithStatusCode
(
400
).
WithBodyAsJson
(
bodyContent
));
await
Assert
.
ThrowsExceptionAsync
<
ServerResponseException
>(
async
()
=>
await
devkitConnector
.
GetDevices
());
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment