Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
ruby-liudesk-cmdb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LiU IT - Infrastructure
ruby-liudesk-cmdb
Commits
0e0a957c
Verified
Commit
0e0a957c
authored
2 years ago
by
Alexander Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
Slightly simplify error handling for requests
parent
94fefd7e
No related branches found
No related tags found
No related merge requests found
Pipeline
#100210
failed
2 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/liudesk_cmdb.rb
+3
-3
3 additions, 3 deletions
lib/liudesk_cmdb.rb
lib/liudesk_cmdb/client.rb
+2
-10
2 additions, 10 deletions
lib/liudesk_cmdb/client.rb
with
5 additions
and
13 deletions
lib/liudesk_cmdb.rb
+
3
−
3
View file @
0e0a957c
...
...
@@ -30,9 +30,9 @@ module LiudeskCMDB
attr_reader
:code
,
:errors
def
self
.
create
(
body
,
code
)
return
ServerError
.
new
body
,
code
if
code
.
to_i
>=
500
&&
code
.
to_i
<
600
case
code
when
"500"
InternalServerError
.
new
body
,
code
when
"403"
ForbiddenError
.
new
body
,
code
when
"404"
...
...
@@ -67,7 +67,7 @@ module LiudeskCMDB
class
ForbiddenError
<
RequestError
;
end
class
NotFoundError
<
RequestError
;
end
class
UnprocessableError
<
RequestError
;
end
class
Internal
ServerError
<
RequestError
;
end
class
ServerError
<
RequestError
;
end
# Data models
module
Models
...
...
This diff is collapsed.
Click to expand it.
lib/liudesk_cmdb/client.rb
+
2
−
10
View file @
0e0a957c
...
...
@@ -42,12 +42,7 @@ module LiudeskCMDB
if
query
query
=
URI
.
encode_www_form
(
query
)
if
query
.
is_a?
Hash
if
uri
.
query
&
.
length
&
.
positive?
uri
.
query
+=
"&
#{
query
}
"
else
uri
.
query
=
query
end
uri
.
query
=
[
uri
.
query
,
query
].
reject
{
|
q
|
q
.
nil?
||
q
.
empty?
}.
join
"&"
end
request
=
Net
::
HTTP
.
const_get
(
method
.
to_s
.
capitalize
).
new
(
uri
.
request_uri
)
...
...
@@ -62,7 +57,6 @@ module LiudeskCMDB
request
[
"Content-Type"
]
=
"application/json"
request
.
body
=
body
end
print_req_res
request
if
logger
.
debug?
...
...
@@ -73,9 +67,7 @@ module LiudeskCMDB
response
.
value
response
.
body
rescue
Net
::
HTTPFatalError
raise
LiudeskCMDB
::
RequestError
.
create
(
response
.
message
,
response
.
code
)
rescue
Net
::
HTTPClientException
rescue
Net
::
HTTPClientException
,
Net
::
HTTPFatalError
begin
body
=
JSON
.
parse
(
response
.
body
)
rescue
StandardError
=>
e
...
...
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