Skip to content

Commit

Permalink
Add exception handling for JSON::ParserError
Browse files Browse the repository at this point in the history
  • Loading branch information
ton31337 committed Nov 16, 2017
1 parent f94e38a commit b93fb0d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion libraries/organization_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ def _do_request(grafana_options, payload=nil)
success: grafana_options[:success_msg],
unknown_code: grafana_options[:unknown_code_msg]
)
JSON.parse(response.body)
begin
JSON.parse(response.body)
rescue JSON::ParserError
nil
end
rescue BackendError
nil
end
Expand Down
2 changes: 1 addition & 1 deletion resources/organization.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
actions :create, :update, :delete
default_action :create

state_attrs :organization_name
state_attrs :name

# Grafana options
attribute :host, kind_of: String, default: 'localhost'
Expand Down

0 comments on commit b93fb0d

Please sign in to comment.