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
78f8c0d3
Verified
Commit
78f8c0d3
authored
2 years ago
by
Alexander Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
Improve request error handling
parent
00fff23d
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
+16
-1
16 additions, 1 deletion
lib/liudesk_cmdb.rb
lib/liudesk_cmdb/client.rb
+1
-1
1 addition, 1 deletion
lib/liudesk_cmdb/client.rb
with
17 additions
and
2 deletions
lib/liudesk_cmdb.rb
+
16
−
1
View file @
78f8c0d3
...
...
@@ -29,9 +29,22 @@ module LiudeskCMDB
class
RequestError
<
Error
attr_reader
:code
,
:errors
def
self
.
create
(
body
,
code
)
case
code
when
"404"
NotFoundError
.
new
body
,
code
else
RequestError
.
new
body
,
code
end
end
def
initialize
(
body
,
code
)
@code
=
code
@errors
=
body
[
"errors"
]
||
body
[
:errors
]
@errors
=
if
body
.
is_a?
String
[{
message:
body
}]
else
body
[
"errors"
]
||
body
[
:errors
]
end
super
message
end
...
...
@@ -45,6 +58,8 @@ module LiudeskCMDB
end
end
class
NotFoundError
<
RequestError
;
end
# Data models
module
Models
def
self
.
const_missing
(
const
)
...
...
This diff is collapsed.
Click to expand it.
lib/liudesk_cmdb/client.rb
+
1
−
1
View file @
78f8c0d3
...
...
@@ -75,7 +75,7 @@ module LiudeskCMDB
response
.
body
rescue
Net
::
HTTPClientException
body
=
JSON
.
parse
(
response
.
body
)
raise
LiudeskCMDB
::
RequestError
,
body
,
response
.
code
raise
LiudeskCMDB
::
RequestError
.
create
(
body
,
response
.
code
)
end
def
pretty_print_instance_variables
...
...
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