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
94fefd7e
Verified
Commit
94fefd7e
authored
2 years ago
by
Alexander Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
Even more error handling improvements
parent
b230d3d3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/liudesk_cmdb.rb
+6
-0
6 additions, 0 deletions
lib/liudesk_cmdb.rb
lib/liudesk_cmdb/client.rb
+8
-1
8 additions, 1 deletion
lib/liudesk_cmdb/client.rb
with
14 additions
and
1 deletion
lib/liudesk_cmdb.rb
+
6
−
0
View file @
94fefd7e
...
...
@@ -33,8 +33,12 @@ module LiudeskCMDB
case
code
when
"500"
InternalServerError
.
new
body
,
code
when
"403"
ForbiddenError
.
new
body
,
code
when
"404"
NotFoundError
.
new
body
,
code
when
"422"
UnprocessableError
.
new
body
,
code
else
RequestError
.
new
body
,
code
end
...
...
@@ -60,7 +64,9 @@ module LiudeskCMDB
end
end
class
ForbiddenError
<
RequestError
;
end
class
NotFoundError
<
RequestError
;
end
class
UnprocessableError
<
RequestError
;
end
class
InternalServerError
<
RequestError
;
end
# Data models
...
...
This diff is collapsed.
Click to expand it.
lib/liudesk_cmdb/client.rb
+
8
−
1
View file @
94fefd7e
...
...
@@ -76,7 +76,14 @@ module LiudeskCMDB
rescue
Net
::
HTTPFatalError
raise
LiudeskCMDB
::
RequestError
.
create
(
response
.
message
,
response
.
code
)
rescue
Net
::
HTTPClientException
body
=
JSON
.
parse
(
response
.
body
)
rescue
body
begin
body
=
JSON
.
parse
(
response
.
body
)
rescue
StandardError
=>
e
logger
.
debug
"Failed to parse error response -
#{
e
.
class
}
:
#{
e
}
"
body
=
response
.
body
body
=
response
.
message
if
body
.
nil?
||
body
.
empty?
end
raise
LiudeskCMDB
::
RequestError
.
create
(
body
,
response
.
code
)
end
...
...
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