wavefront-sdk 3.3.0 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c8e79cd1093418262ff15a58819de1cadedcc6a98c0450199e7b40b14424dc8
4
- data.tar.gz: 6feebdd5b6169d943ca38277f1a37af9cd596da15537f1ae3fb0d9946c32673d
3
+ metadata.gz: 2bbfb49f0c6292fa72ed5496a636e5627fc0a6a06df639f737703acff90600a9
4
+ data.tar.gz: 676f628b99a7618736f547c8de353b323a0bb0e0978a9a9aee42bc58c53abbae
5
5
  SHA512:
6
- metadata.gz: 68f31929e91bd8bf2cc49127b4e2d77d4fc901eaa945941d359b7e4a8ecfe198082f455619c2bf5f8d2baead9738f6caf55373529167c8e4201e786dc5239b91
7
- data.tar.gz: 525ec79d3c53ffa102c6298ea2e041ef0666c0c21ce275ecd0ca24fa9e863c0984fea09e1a34d3bde16700539db987e0615bfff5e2c26282e8e6a1bc61f86247
6
+ metadata.gz: 2bc53c1bab53f1a274dc225cadcedc4db619b3ecd6b6b26c89b55013b1829e805f45757d570413468bd347c1739b386a33fbdbe18a8f0890642fb16be7397b78
7
+ data.tar.gz: f9479dcefc166eb4a1463e06b8ad496fc90e18ebada48c69dce636942da4492bf9dd414b19bf1d03fdec744ff5294a52dcf122e886848eadb60d19997c7954c5
data/HISTORY.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.3.1
4
+ * Better handling of query errors.
5
+
3
6
  ## 3.3.0
4
7
  * Reflect the way the API ACL format has changed.
5
8
 
@@ -1,4 +1,4 @@
1
1
  require 'pathname'
2
2
 
3
- WF_SDK_VERSION = '3.3.0'.freeze
3
+ WF_SDK_VERSION = '3.3.1'.freeze
4
4
  WF_SDK_LOCATION = Pathname.new(__FILE__).dirname.parent.parent.parent
@@ -76,9 +76,16 @@ module Wavefront
76
76
  # Fake a response which looks like we get from all the other
77
77
  # paths. The default response is a single array.
78
78
  #
79
+ # I don't know if something has changed in the API, but sending
80
+ # a complete nonsense query like 'st("some.series")' returns an
81
+ # error message, but with a 200 code. So we fudge a 400 if we
82
+ # see a message.
83
+ #
79
84
  def response_shim(body, status)
80
85
  resp, err_msg = parsed_response(body)
81
86
 
87
+ status = 400 if status == 200 && !err_msg.empty?
88
+
82
89
  { response: resp,
83
90
  status: { result: status == 200 ? 'OK' : 'ERROR',
84
91
  message: err_msg,
@@ -87,11 +94,23 @@ module Wavefront
87
94
 
88
95
  # A bad query doesn't send back a JSON object. It sends back a
89
96
  # string with an embedded message.
97
+ # @return [Array] [parsed body of response, error_message]. One
98
+ # or the other
90
99
  #
91
100
  def parsed_response(body)
92
101
  [JSON.parse(body), '']
93
102
  rescue JSON::ParserError
94
- ['', body.match(/message='([^']+)'/).captures.first]
103
+ ['', extract_error_message(body)]
104
+ end
105
+
106
+ # There ought to be a message= block in the response, but
107
+ # sometimes there isn't. So far it seems that in this second
108
+ # case, the message is on its own line.
109
+ #
110
+ def extract_error_message(body)
111
+ body.match(/message='([^']+)'/).captures.first
112
+ rescue StandardError
113
+ body.lines.last.strip
95
114
  end
96
115
  end
97
116
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wavefront-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Fisher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-09 00:00:00.000000000 Z
11
+ date: 2019-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable