b2-client 1.0.2 → 1.0.3

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: e0be79261fee4bcca3e1ba5a8dbe172bc505d38a35b79a0b3e25f81de26a900a
4
- data.tar.gz: 593efe787fb433de833a8acb964f470ee9f5bc27c71b6ada97af1284e9d955e7
3
+ metadata.gz: 90351edd9bc9e92242bf093a853d0ee2c9a2f2dc7bd5c6d5f9d4a11f966c7082
4
+ data.tar.gz: f244abd20dafe43ea6e1c259637ce6d8182d6595997e7148dc4e313128fafbf5
5
5
  SHA512:
6
- metadata.gz: 8eb2b33f95494b125c0397de1355063b256c420a717ca4eb0ffd0772f815afd2e094d8dbb7ab22904ef8f7ac651a5e019aa19137e3127a46fa1b6e97982d60d7
7
- data.tar.gz: 5505cb044eba0400384f2d072fa079bd7adfa8a5a3826719825644ab819d8945f5966cbc69f6485214cddc81a9f8890fbc2b79c72f2e0c110f9418ef474f91bf
6
+ metadata.gz: f8062646a787ed2d5fdd7b7d1ffe4ccd359f3dc4fed0f43f8210bae0c7d20dbcaa9cb552cb44b7a26a4160a9729d9dbf140276c8adf39f42f74c022f9ece3cc8
7
+ data.tar.gz: af4f4d63cb24311935f3fcb273b294c61597624ed15dca8def02ebffade49e618d549169bc0708421d005dca1fcebb9c58c7acd8da7e0f7ade326cee8ab8dbe1
data/lib/b2.rb CHANGED
@@ -2,6 +2,7 @@ require 'uri'
2
2
  require 'json'
3
3
  require 'net/http'
4
4
 
5
+ require File.expand_path('../b2/errors', __FILE__)
5
6
  require File.expand_path('../b2/file', __FILE__)
6
7
  require File.expand_path('../b2/bucket', __FILE__)
7
8
  require File.expand_path('../b2/connection', __FILE__)
@@ -113,8 +113,19 @@ class B2
113
113
  if digestor.hexdigest != response['X-Bz-Content-Sha1']
114
114
  raise 'file error'
115
115
  end
116
+ when Net::HTTPNotFound
117
+ raise B2::NotFound.new(JSON.parse(response.body)['message'])
116
118
  else
117
- raise response.body
119
+ begin
120
+ body = JSON.parse(response.body)
121
+ if body['code'] == 'not_found'
122
+ raise B2::NotFound(body['message'])
123
+ else
124
+ raise "#{body['code']} (#{body['message']})"
125
+ end
126
+ rescue
127
+ raise response.body
128
+ end
118
129
  end
119
130
  end
120
131
  end
@@ -0,0 +1,9 @@
1
+ class B2
2
+
3
+ class Error < StandardError
4
+ end
5
+
6
+ class NotFound < Error
7
+ end
8
+
9
+ end
@@ -1,3 +1,3 @@
1
1
  class B2
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: b2-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Bracy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-20 00:00:00.000000000 Z
11
+ date: 2018-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -39,6 +39,7 @@ files:
39
39
  - lib/b2/bucket.rb
40
40
  - lib/b2/client.rb
41
41
  - lib/b2/connection.rb
42
+ - lib/b2/errors.rb
42
43
  - lib/b2/file.rb
43
44
  - lib/b2/upload_chunker.rb
44
45
  - lib/b2/version.rb