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
b230d3d3
"bindings/git@gitlab.liu.se:irt/sleuthkit.git" did not exist on "e8b88b1b0f85e52835afee28f06da75c386d581a"
Verified
Commit
b230d3d3
authored
2 years ago
by
Alexander Olofsson
Browse files
Options
Downloads
Patches
Plain Diff
Even more improvements to error handling
parent
78f8c0d3
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
+7
-4
7 additions, 4 deletions
lib/liudesk_cmdb.rb
lib/liudesk_cmdb/client.rb
+3
-1
3 additions, 1 deletion
lib/liudesk_cmdb/client.rb
with
10 additions
and
5 deletions
lib/liudesk_cmdb.rb
+
7
−
4
View file @
b230d3d3
...
...
@@ -31,6 +31,8 @@ module LiudeskCMDB
def
self
.
create
(
body
,
code
)
case
code
when
"500"
InternalServerError
.
new
body
,
code
when
"404"
NotFoundError
.
new
body
,
code
else
...
...
@@ -40,10 +42,10 @@ module LiudeskCMDB
def
initialize
(
body
,
code
)
@code
=
code
@errors
=
if
body
.
is_a?
String
[{
message:
body
}]
@errors
=
if
body
.
is_a?
Hash
body
[
"errors"
]
||
body
[
:errors
]
||
[{
message:
body
.
to_json
}]
else
body
[
"errors"
]
||
body
[
:errors
]
[{
message:
body
}
]
end
super
message
...
...
@@ -53,12 +55,13 @@ module LiudeskCMDB
if
@errors
.
is_a?
Hash
@errors
.
values
.
flatten
.
join
", "
else
@errors
.
map
{
|
err
|
err
[
"message"
]
||
err
[
:message
]
}.
join
", "
@errors
.
map
{
|
err
|
[
err
[
"fieldName"
],
err
[
"message"
]
||
err
[
:message
]
].
compact
.
join
(
" - "
)
}.
join
", "
end
end
end
class
NotFoundError
<
RequestError
;
end
class
InternalServerError
<
RequestError
;
end
# Data models
module
Models
...
...
This diff is collapsed.
Click to expand it.
lib/liudesk_cmdb/client.rb
+
3
−
1
View file @
b230d3d3
...
...
@@ -73,8 +73,10 @@ module LiudeskCMDB
response
.
value
response
.
body
rescue
Net
::
HTTPFatalError
raise
LiudeskCMDB
::
RequestError
.
create
(
response
.
message
,
response
.
code
)
rescue
Net
::
HTTPClientException
body
=
JSON
.
parse
(
response
.
body
)
body
=
JSON
.
parse
(
response
.
body
)
rescue
body
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